36aedf9df5512470654a3e14ef0217890a97ceb2
1 # Copyright (c) 2016, Matt Layman
5 """Base type for TAP data.
7 TAP is a line based protocol. Thus, the most primitive type is a line.
11 raise NotImplementedError
15 """Information about an individual test line."""
18 self
, ok
, number
=None, description
='', directive
=None,
22 self
._number
= int(number
)
24 # The number may be an empty string so explicitly set to None.
26 self
._description
= description
27 self
.directive
= directive
28 self
.diagnostics
= diagnostics
32 """:returns: ``test``"""
45 """Get the test number.
52 def description(self
):
53 """Get the description."""
54 return self
._description
58 """Check if this test was skipped.
62 return self
.directive
.skip
66 """Check if this test was a TODO.
70 return self
.directive
.todo
77 if self
.directive
is not None and self
.directive
.text
:
78 directive
= ' # {0}'.format(self
.directive
.text
)
80 if self
.diagnostics
is not None:
81 diagnostics
= '\n' + self
.diagnostics
.rstrip()
82 return "{0}ok {1} - {2}{3}{4}".format(
83 is_not
, self
.number
, self
.description
, directive
, diagnostics
)
87 """A plan line to indicate how many tests to expect."""
89 def __init__(self
, expected_tests
, directive
=None):
90 self
._expected
_tests
= expected_tests
91 self
.directive
= directive
95 """:returns: ``plan``"""
99 def expected_tests(self
):
100 """Get the number of expected tests.
104 return self
._expected
_tests
108 """Check if this plan should skip the file.
112 return self
.directive
.skip
115 class Diagnostic(Line
):
116 """A diagnostic line (i.e. anything starting with a hash)."""
118 def __init__(self
, text
):
123 """:returns: ``diagnostic``"""
133 """A bail out line (i.e. anything starting with 'Bail out!')."""
135 def __init__(self
, reason
):
136 self
._reason
= reason
140 """:returns: ``bail``"""
145 """Get the reason."""
150 """A version line (i.e. of the form 'TAP version 13')."""
152 def __init__(self
, version
):
153 self
._version
= version
157 """:returns: ``version``"""
162 """Get the version number.
170 """A line that represents something that is not a known TAP line.
172 This exists for the purpose of a Null Object pattern.
176 """:returns: ``unknown``"""
This page took 0.032112 seconds and 4 git commands to generate.