31829582a1dc3b2856f99669af6449f516e5b8dd
1 # SPDX-License-Identifier: BSD-2-Clause
3 # Copyright (c) 2016, Matt Layman
7 """Base type for TAP data.
9 TAP is a line based protocol. Thus, the most primitive type is a line.
14 raise NotImplementedError
18 """Information about an individual test line."""
21 self
, ok
, number
=None, description
='', directive
=None, diagnostics
=None
25 self
._number
= int(number
)
27 # The number may be an empty string so explicitly set to None.
29 self
._description
= description
30 self
.directive
= directive
31 self
.diagnostics
= diagnostics
35 """:returns: ``test``"""
48 """Get the test number.
55 def description(self
):
56 """Get the description."""
57 return self
._description
61 """Check if this test was skipped.
65 return self
.directive
.skip
69 """Check if this test was a TODO.
73 return self
.directive
.todo
80 if self
.directive
is not None and self
.directive
.text
:
81 directive
= ' # {0}'.format(self
.directive
.text
)
83 if self
.diagnostics
is not None:
84 diagnostics
= '\n' + self
.diagnostics
.rstrip()
85 return "{0}ok {1} - {2}{3}{4}".format(
86 is_not
, self
.number
, self
.description
, directive
, diagnostics
91 """A plan line to indicate how many tests to expect."""
93 def __init__(self
, expected_tests
, directive
=None):
94 self
._expected
_tests
= expected_tests
95 self
.directive
= directive
99 """:returns: ``plan``"""
103 def expected_tests(self
):
104 """Get the number of expected tests.
108 return self
._expected
_tests
112 """Check if this plan should skip the file.
116 return self
.directive
.skip
119 class Diagnostic(Line
):
120 """A diagnostic line (i.e. anything starting with a hash)."""
122 def __init__(self
, text
):
127 """:returns: ``diagnostic``"""
137 """A bail out line (i.e. anything starting with 'Bail out!')."""
139 def __init__(self
, reason
):
140 self
._reason
= reason
144 """:returns: ``bail``"""
149 """Get the reason."""
154 """A version line (i.e. of the form 'TAP version 13')."""
156 def __init__(self
, version
):
157 self
._version
= version
161 """:returns: ``version``"""
166 """Get the version number.
174 """A line that represents something that is not a known TAP line.
176 This exists for the purpose of a Null Object pattern.
181 """:returns: ``unknown``"""
This page took 0.033591 seconds and 5 git commands to generate.