Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Contributors
* meejah (https://meejah.ca)
* Michael F. Lamb (http://datagrok.org)
* Nicolas Caniart
* Pierrick Guillaume
* Richard Bosworth
* Ross Burton
* Simon McVittie
8 changes: 8 additions & 0 deletions src/tap/line.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,15 @@ class Unknown(Line):
This exists for the purpose of a Null Object pattern.
"""

def __init__(self, text=None):
self._text = text

@property
def category(self):
""":returns: ``unknown``"""
return "unknown"

@property
def text(self):
"""Get the text."""
return self._text
4 changes: 2 additions & 2 deletions src/tap/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def parse_line(self, text, fh=None):
if match:
return self._parse_version(match)

return Unknown()
return Unknown(text)

def _parse_plan(self, match):
"""Parse a matching plan line."""
Expand All @@ -142,7 +142,7 @@ def _parse_plan(self, match):

# Only SKIP directives are allowed in the plan.
if directive.text and not directive.skip:
return Unknown()
return Unknown(match.string)

return Plan(expected_tests, directive)

Expand Down
8 changes: 6 additions & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ def test_finds_directive(self):
def test_unrecognizable_line(self):
"""The parser returns an unrecognizable line."""
parser = Parser()
test_line = "This is not a valid TAP line. # srsly"

line = parser.parse_line("This is not a valid TAP line. # srsly")
line = parser.parse_line(test_line)

self.assertEqual("unknown", line.category)
self.assertEqual(test_line, line.text)

def test_diagnostic_line(self):
"""The parser extracts a diagnostic line."""
Expand Down Expand Up @@ -171,10 +173,12 @@ def test_finds_plan_with_skip(self):
def test_ignores_plan_with_any_non_skip_directive(self):
"""The parser only recognizes SKIP directives in plans."""
parser = Parser()
test_line = "1..42 # TODO will not work."

line = parser.parse_line("1..42 # TODO will not work.")
line = parser.parse_line(test_line)

self.assertEqual("unknown", line.category)
self.assertEqual(test_line, line.text)

def test_parses_text(self):
sample = inspect.cleandoc(
Expand Down