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.
13 raise NotImplementedError
17 """Information about an individual test line."""
20 self
, ok
, number
=None, description
='', directive
=None,
24 self
._number
= int(number
)
26 # The number may be an empty string so explicitly set to None.
28 self
._description
= description
29 self
.directive
= directive
30 self
.diagnostics
= diagnostics
34 """:returns: ``test``"""
47 """Get the test number.
54 def description(self
):
55 """Get the description."""
56 return self
._description
60 """Check if this test was skipped.
64 return self
.directive
.skip
68 """Check if this test was a TODO.
72 return self
.directive
.todo
79 if self
.directive
is not None and self
.directive
.text
:
80 directive
= ' # {0}'.format(self
.directive
.text
)
82 if self
.diagnostics
is not None:
83 diagnostics
= '\n' + self
.diagnostics
.rstrip()
84 return "{0}ok {1} - {2}{3}{4}".format(
85 is_not
, self
.number
, self
.description
, directive
, diagnostics
)
89 """A plan line to indicate how many tests to expect."""
91 def __init__(self
, expected_tests
, directive
=None):
92 self
._expected
_tests
= expected_tests
93 self
.directive
= directive
97 """:returns: ``plan``"""
101 def expected_tests(self
):
102 """Get the number of expected tests.
106 return self
._expected
_tests
110 """Check if this plan should skip the file.
114 return self
.directive
.skip
117 class Diagnostic(Line
):
118 """A diagnostic line (i.e. anything starting with a hash)."""
120 def __init__(self
, text
):
125 """:returns: ``diagnostic``"""
135 """A bail out line (i.e. anything starting with 'Bail out!')."""
137 def __init__(self
, reason
):
138 self
._reason
= reason
142 """:returns: ``bail``"""
147 """Get the reason."""
152 """A version line (i.e. of the form 'TAP version 13')."""
154 def __init__(self
, version
):
155 self
._version
= version
159 """:returns: ``version``"""
164 """Get the version number.
172 """A line that represents something that is not a known TAP line.
174 This exists for the purpose of a Null Object pattern.
178 """:returns: ``unknown``"""
This page took 0.033537 seconds and 5 git commands to generate.