/usr/lib/python3/dist-packages/tap/line.py is in python3-tap 2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | # Copyright (c) 2018, Matt Layman and contributors
class Line(object):
"""Base type for TAP data.
TAP is a line based protocol. Thus, the most primitive type is a line.
"""
@property
def category(self):
raise NotImplementedError
class Result(Line):
"""Information about an individual test line."""
def __init__(
self, ok, number=None, description='', directive=None,
diagnostics=None):
self._ok = ok
if number:
self._number = int(number)
else:
# The number may be an empty string so explicitly set to None.
self._number = None
self._description = description
self.directive = directive
self.diagnostics = diagnostics
@property
def category(self):
""":returns: ``test``"""
return 'test'
@property
def ok(self):
"""Get the ok status.
:rtype: bool
"""
return self._ok
@property
def number(self):
"""Get the test number.
:rtype: int
"""
return self._number
@property
def description(self):
"""Get the description."""
return self._description
@property
def skip(self):
"""Check if this test was skipped.
:rtype: bool
"""
return self.directive.skip
@property
def todo(self):
"""Check if this test was a TODO.
:rtype: bool
"""
return self.directive.todo
def __str__(self):
is_not = ''
if not self.ok:
is_not = 'not '
directive = ''
if self.directive is not None and self.directive.text:
directive = ' # {0}'.format(self.directive.text)
diagnostics = ''
if self.diagnostics is not None:
diagnostics = '\n' + self.diagnostics.rstrip()
return "{0}ok {1} - {2}{3}{4}".format(
is_not, self.number, self.description, directive, diagnostics)
class Plan(Line):
"""A plan line to indicate how many tests to expect."""
def __init__(self, expected_tests, directive=None):
self._expected_tests = expected_tests
self.directive = directive
@property
def category(self):
""":returns: ``plan``"""
return 'plan'
@property
def expected_tests(self):
"""Get the number of expected tests.
:rtype: int
"""
return self._expected_tests
@property
def skip(self):
"""Check if this plan should skip the file.
:rtype: bool
"""
return self.directive.skip
class Diagnostic(Line):
"""A diagnostic line (i.e. anything starting with a hash)."""
def __init__(self, text):
self._text = text
@property
def category(self):
""":returns: ``diagnostic``"""
return 'diagnostic'
@property
def text(self):
"""Get the text."""
return self._text
class Bail(Line):
"""A bail out line (i.e. anything starting with 'Bail out!')."""
def __init__(self, reason):
self._reason = reason
@property
def category(self):
""":returns: ``bail``"""
return 'bail'
@property
def reason(self):
"""Get the reason."""
return self._reason
class Version(Line):
"""A version line (i.e. of the form 'TAP version 13')."""
def __init__(self, version):
self._version = version
@property
def category(self):
""":returns: ``version``"""
return 'version'
@property
def version(self):
"""Get the version number.
:rtype: int
"""
return self._version
class Unknown(Line):
"""A line that represents something that is not a known TAP line.
This exists for the purpose of a Null Object pattern.
"""
@property
def category(self):
""":returns: ``unknown``"""
return 'unknown'
|