testtools 2.8.7__tar.gz → 2.9.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {testtools-2.8.7 → testtools-2.9.1}/NEWS +20 -2
- {testtools-2.8.7 → testtools-2.9.1}/PKG-INFO +3 -3
- {testtools-2.8.7 → testtools-2.9.1}/doc/for-test-authors.rst +3 -1
- {testtools-2.8.7 → testtools-2.9.1}/pyproject.toml +5 -5
- {testtools-2.8.7 → testtools-2.9.1}/tests/helpers.py +2 -1
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_basic.py +82 -37
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_dict.py +2 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_filesystem.py +62 -35
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_higherorder.py +3 -2
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_impl.py +21 -8
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_assert_that.py +27 -13
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_content.py +7 -2
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_content_type.py +6 -4
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_fixturesupport.py +1 -1
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_run.py +5 -3
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_testcase.py +49 -34
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_testresult.py +109 -38
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_testsuite.py +6 -8
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_with_with.py +3 -1
- testtools-2.9.1/tests/twistedsupport/__init__.py +33 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/twistedsupport/test_matchers.py +4 -1
- {testtools-2.8.7 → testtools-2.9.1}/tests/twistedsupport/test_runtest.py +10 -10
- testtools-2.9.1/testtools/_types.py +8 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/_version.py +2 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/compat.py +11 -1
- {testtools-2.8.7 → testtools-2.9.1}/testtools/content.py +2 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/content_type.py +4 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/__init__.py +4 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_basic.py +63 -44
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_datastructures.py +3 -3
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_dict.py +2 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_doctest.py +2 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_exception.py +12 -16
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_filesystem.py +2 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_warnings.py +1 -1
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/test.py +15 -17
- {testtools-2.8.7 → testtools-2.9.1}/testtools/monkey.py +7 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/run.py +29 -85
- {testtools-2.8.7 → testtools-2.9.1}/testtools/runtest.py +3 -3
- {testtools-2.8.7 → testtools-2.9.1}/testtools/testcase.py +148 -110
- {testtools-2.8.7 → testtools-2.9.1}/testtools/testresult/__init__.py +0 -2
- {testtools-2.8.7 → testtools-2.9.1}/testtools/testresult/doubles.py +7 -12
- {testtools-2.8.7 → testtools-2.9.1}/testtools/testresult/real.py +60 -62
- {testtools-2.8.7 → testtools-2.9.1}/testtools/testsuite.py +10 -11
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/_matchers.py +6 -4
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/_runtest.py +1 -4
- {testtools-2.8.7 → testtools-2.9.1}/tox.ini +1 -1
- testtools-2.8.7/tests/twistedsupport/__init__.py +0 -21
- {testtools-2.8.7 → testtools-2.9.1}/.git-blame-ignore-revs +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.github/dependabot.yaml +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.github/workflows/publish.yml +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.github/workflows/test.yml +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.gitignore +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.gitreview +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/.testr.conf +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/LICENSE +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/MANIFEST.in +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/Makefile +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/README.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/disperse.conf +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/Makefile +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/_static/placeholder.txt +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/_templates/placeholder.txt +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/api.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/conf.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/for-framework-folk.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/hacking.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/index.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/make.bat +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/news.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/overview.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/doc/twisted-support.rst +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/readthedocs-requirements.txt +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/requirements.txt +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/scripts/README +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/scripts/all-pythons +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/scripts/update-rtfd +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_const.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_datastructures.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_doctest.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_exception.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/matchers/test_warnings.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/samplecases.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_compat.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_helpers.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_monkey.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_runtest.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/test_tags.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/twistedsupport/_helpers.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/twistedsupport/test_deferred.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/tests/twistedsupport/test_spinner.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/_version.pyi +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/assertions.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/helpers.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_const.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_higherorder.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/matchers/_impl.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/py.typed +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/tags.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/tests/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/tests/helpers.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/tests/matchers/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/tests/matchers/helpers.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/__init__.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/_deferred.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/_deferreddebug.py +0 -0
- {testtools-2.8.7 → testtools-2.9.1}/testtools/twistedsupport/_spinner.py +0 -0
|
@@ -3,8 +3,26 @@ testtools NEWS
|
|
|
3
3
|
|
|
4
4
|
Changes and improvements to testtools_, grouped by release.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
2.9.1
|
|
7
|
+
~~~~~
|
|
8
|
+
|
|
9
|
+
Improvements
|
|
10
|
+
------------
|
|
11
|
+
* Don't leak testtools-specific exception details into
|
|
12
|
+
``unittest.TestResult`` error reports when using a stdlib ``TestResult``.
|
|
13
|
+
(Jelmer Vernooij, #607)
|
|
14
|
+
|
|
15
|
+
2.9.0
|
|
16
|
+
~~~~~
|
|
17
|
+
|
|
18
|
+
Improvements
|
|
19
|
+
------------
|
|
20
|
+
* Add ``LessThanOrEqual`` and ``GreaterThanOrEqual`` matchers.
|
|
21
|
+
(Julian Edwards, #594)
|
|
22
|
+
|
|
23
|
+
* Improve type annotations throughout the codebase, including compatibility
|
|
24
|
+
fixes for mypy 1.20.0.
|
|
25
|
+
(Stephen Finucane, #587, #591, #592, #593, #600)
|
|
8
26
|
|
|
9
27
|
2.8.7
|
|
10
28
|
~~~~~
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: testtools
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.9.1
|
|
4
4
|
Summary: Extensions to the Python standard library unit testing framework
|
|
5
5
|
Project-URL: Homepage, https://github.com/testing-cabal/testtools
|
|
6
6
|
Author-email: "Jonathan M. Lange" <jml+testtools@mumak.net>
|
|
@@ -25,8 +25,8 @@ Classifier: Topic :: Software Development :: Testing
|
|
|
25
25
|
Classifier: Typing :: Typed
|
|
26
26
|
Requires-Python: >=3.10
|
|
27
27
|
Provides-Extra: dev
|
|
28
|
-
Requires-Dist: mypy>=1.
|
|
29
|
-
Requires-Dist: ruff==0.15.
|
|
28
|
+
Requires-Dist: mypy>=1.20.0; extra == 'dev'
|
|
29
|
+
Requires-Dist: ruff==0.15.9; extra == 'dev'
|
|
30
30
|
Requires-Dist: typing-extensions; (python_version < '3.11') and extra == 'dev'
|
|
31
31
|
Provides-Extra: test
|
|
32
32
|
Requires-Dist: testresources; extra == 'test'
|
|
@@ -937,7 +937,9 @@ the ``Mismatch`` knows how to describe a failure to match.
|
|
|
937
937
|
|
|
938
938
|
Here's an example matcher::
|
|
939
939
|
|
|
940
|
-
|
|
940
|
+
from testtools.matchers import Matcher
|
|
941
|
+
|
|
942
|
+
class IsDivisibleBy(Matcher):
|
|
941
943
|
"""Match if a number is divisible by another number."""
|
|
942
944
|
def __init__(self, divider):
|
|
943
945
|
self.divider = divider
|
|
@@ -37,8 +37,8 @@ Homepage = "https://github.com/testing-cabal/testtools"
|
|
|
37
37
|
test = ["testscenarios", "testresources"]
|
|
38
38
|
twisted = ["Twisted", "fixtures"]
|
|
39
39
|
dev = [
|
|
40
|
-
"ruff==0.15.
|
|
41
|
-
"mypy>=1.
|
|
40
|
+
"ruff==0.15.9",
|
|
41
|
+
"mypy>=1.20.0",
|
|
42
42
|
"typing-extensions;python_version<'3.11'",
|
|
43
43
|
]
|
|
44
44
|
|
|
@@ -63,9 +63,9 @@ python_version = "3.10"
|
|
|
63
63
|
show_column_numbers = true
|
|
64
64
|
show_error_context = true
|
|
65
65
|
strict = true
|
|
66
|
-
# this
|
|
67
|
-
#
|
|
68
|
-
|
|
66
|
+
# remove this when 1.20.1 is released
|
|
67
|
+
# https://github.com/python/mypy/issues/21137
|
|
68
|
+
warn_unused_configs = false
|
|
69
69
|
# FIXME(stephenfin): We should remove this
|
|
70
70
|
implicit_reexport = true
|
|
71
71
|
exclude = 'doc'
|
|
@@ -13,6 +13,7 @@ from testtools.content import StackLinesContent
|
|
|
13
13
|
from testtools.matchers import (
|
|
14
14
|
AfterPreprocessing,
|
|
15
15
|
Equals,
|
|
16
|
+
Matcher,
|
|
16
17
|
MatchesDict,
|
|
17
18
|
MatchesListwise,
|
|
18
19
|
)
|
|
@@ -108,7 +109,7 @@ class FullStackRunTest(runtest.RunTest):
|
|
|
108
109
|
return run_with_stack_hidden(False, super()._run_user, fn, *args, **kwargs)
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
class MatchesEvents:
|
|
112
|
+
class MatchesEvents(Matcher[list[tuple[str, ...]]]):
|
|
112
113
|
"""Match a list of test result events.
|
|
113
114
|
|
|
114
115
|
Specify events as a data structure. Ordinary Python objects within this
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Copyright (c) 2008-2012 testtools developers. See LICENSE for details.
|
|
2
2
|
|
|
3
3
|
import re
|
|
4
|
-
from typing import ClassVar
|
|
4
|
+
from typing import Any, ClassVar
|
|
5
5
|
|
|
6
6
|
from testtools import TestCase
|
|
7
7
|
from testtools.compat import text_repr
|
|
@@ -12,10 +12,12 @@ from testtools.matchers._basic import (
|
|
|
12
12
|
EndsWith,
|
|
13
13
|
Equals,
|
|
14
14
|
GreaterThan,
|
|
15
|
+
GreaterThanOrEqual,
|
|
15
16
|
HasLength,
|
|
16
17
|
Is,
|
|
17
18
|
IsInstance,
|
|
18
19
|
LessThan,
|
|
20
|
+
LessThanOrEqual,
|
|
19
21
|
MatchesRegex,
|
|
20
22
|
Nearly,
|
|
21
23
|
NotEquals,
|
|
@@ -24,6 +26,7 @@ from testtools.matchers._basic import (
|
|
|
24
26
|
_BinaryMismatch,
|
|
25
27
|
_NotNearlyEqual,
|
|
26
28
|
)
|
|
29
|
+
from testtools.matchers._impl import Matcher
|
|
27
30
|
from testtools.matchers.test import TestMatchersInterface
|
|
28
31
|
|
|
29
32
|
from ..helpers import FullStackRunTest
|
|
@@ -114,9 +117,9 @@ class Test_BinaryMismatch(TestCase):
|
|
|
114
117
|
|
|
115
118
|
|
|
116
119
|
class TestEqualsInterface(TestCase, TestMatchersInterface):
|
|
117
|
-
matches_matcher: ClassVar = Equals(1)
|
|
118
|
-
matches_matches: ClassVar = [1]
|
|
119
|
-
matches_mismatches: ClassVar = [2]
|
|
120
|
+
matches_matcher: ClassVar[Matcher[Any]] = Equals(1)
|
|
121
|
+
matches_matches: ClassVar[list[Any]] = [1]
|
|
122
|
+
matches_mismatches: ClassVar[list[Any]] = [2]
|
|
120
123
|
|
|
121
124
|
str_examples: ClassVar = [
|
|
122
125
|
("Equals(1)", Equals(1)),
|
|
@@ -138,9 +141,9 @@ class TestEqualsInterface(TestCase, TestMatchersInterface):
|
|
|
138
141
|
|
|
139
142
|
|
|
140
143
|
class TestNotEqualsInterface(TestCase, TestMatchersInterface):
|
|
141
|
-
matches_matcher: ClassVar = NotEquals(1)
|
|
142
|
-
matches_matches: ClassVar = [2]
|
|
143
|
-
matches_mismatches: ClassVar = [1]
|
|
144
|
+
matches_matcher: ClassVar[Matcher[Any]] = NotEquals(1)
|
|
145
|
+
matches_matches: ClassVar[list[Any]] = [2]
|
|
146
|
+
matches_mismatches: ClassVar[list[Any]] = [1]
|
|
144
147
|
|
|
145
148
|
str_examples: ClassVar = [
|
|
146
149
|
("NotEquals(1)", NotEquals(1)),
|
|
@@ -154,9 +157,9 @@ class TestIsInterface(TestCase, TestMatchersInterface):
|
|
|
154
157
|
foo = object()
|
|
155
158
|
bar = object()
|
|
156
159
|
|
|
157
|
-
matches_matcher: ClassVar = Is(foo)
|
|
158
|
-
matches_matches: ClassVar = [foo]
|
|
159
|
-
matches_mismatches: ClassVar = [bar, 1]
|
|
160
|
+
matches_matcher: ClassVar[Matcher[Any]] = Is(foo)
|
|
161
|
+
matches_matches: ClassVar[list[Any]] = [foo]
|
|
162
|
+
matches_mismatches: ClassVar[list[Any]] = [bar, 1]
|
|
160
163
|
|
|
161
164
|
str_examples: ClassVar = [("Is(2)", Is(2))]
|
|
162
165
|
|
|
@@ -167,9 +170,9 @@ class TestIsInstanceInterface(TestCase, TestMatchersInterface):
|
|
|
167
170
|
class Foo:
|
|
168
171
|
pass
|
|
169
172
|
|
|
170
|
-
matches_matcher: ClassVar = IsInstance(Foo)
|
|
171
|
-
matches_matches: ClassVar = [Foo()]
|
|
172
|
-
matches_mismatches: ClassVar = [object(), 1, Foo]
|
|
173
|
+
matches_matcher: ClassVar[Matcher[Any]] = IsInstance(Foo)
|
|
174
|
+
matches_matches: ClassVar[list[Any]] = [Foo()]
|
|
175
|
+
matches_mismatches: ClassVar[list[Any]] = [object(), 1, Foo]
|
|
173
176
|
|
|
174
177
|
str_examples: ClassVar = [
|
|
175
178
|
("IsInstance(str)", IsInstance(str)),
|
|
@@ -187,9 +190,9 @@ class TestIsInstanceInterface(TestCase, TestMatchersInterface):
|
|
|
187
190
|
|
|
188
191
|
|
|
189
192
|
class TestLessThanInterface(TestCase, TestMatchersInterface):
|
|
190
|
-
matches_matcher: ClassVar = LessThan(4)
|
|
191
|
-
matches_matches: ClassVar = [-5, 3]
|
|
192
|
-
matches_mismatches: ClassVar = [4, 5, 5000]
|
|
193
|
+
matches_matcher: ClassVar[Matcher[Any]] = LessThan(4)
|
|
194
|
+
matches_matches: ClassVar[list[Any]] = [-5, 3]
|
|
195
|
+
matches_mismatches: ClassVar[list[Any]] = [4, 5, 5000]
|
|
193
196
|
|
|
194
197
|
str_examples: ClassVar = [
|
|
195
198
|
("LessThan(12)", LessThan(12)),
|
|
@@ -202,9 +205,9 @@ class TestLessThanInterface(TestCase, TestMatchersInterface):
|
|
|
202
205
|
|
|
203
206
|
|
|
204
207
|
class TestGreaterThanInterface(TestCase, TestMatchersInterface):
|
|
205
|
-
matches_matcher: ClassVar = GreaterThan(4)
|
|
206
|
-
matches_matches: ClassVar = [5, 8]
|
|
207
|
-
matches_mismatches: ClassVar = [-2, 0, 4]
|
|
208
|
+
matches_matcher: ClassVar[Matcher[Any]] = GreaterThan(4)
|
|
209
|
+
matches_matches: ClassVar[list[Any]] = [5, 8]
|
|
210
|
+
matches_mismatches: ClassVar[list[Any]] = [-2, 0, 4]
|
|
208
211
|
|
|
209
212
|
str_examples: ClassVar = [
|
|
210
213
|
("GreaterThan(12)", GreaterThan(12)),
|
|
@@ -216,10 +219,40 @@ class TestGreaterThanInterface(TestCase, TestMatchersInterface):
|
|
|
216
219
|
]
|
|
217
220
|
|
|
218
221
|
|
|
222
|
+
class TestLessThanOrEqualInterface(TestCase, TestMatchersInterface):
|
|
223
|
+
matches_matcher: ClassVar[Matcher[Any]] = LessThanOrEqual(4)
|
|
224
|
+
matches_matches: ClassVar[list[Any]] = [-5, 3, 4]
|
|
225
|
+
matches_mismatches: ClassVar[list[Any]] = [5, 5000]
|
|
226
|
+
|
|
227
|
+
str_examples: ClassVar = [
|
|
228
|
+
("LessThanOrEqual(12)", LessThanOrEqual(12)),
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
describe_examples: ClassVar = [
|
|
232
|
+
("5 > 4", 5, LessThanOrEqual(4)),
|
|
233
|
+
("6 > 4", 6, LessThanOrEqual(4)),
|
|
234
|
+
]
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
class TestGreaterThanOrEqualInterface(TestCase, TestMatchersInterface):
|
|
238
|
+
matches_matcher: ClassVar[Matcher[Any]] = GreaterThanOrEqual(4)
|
|
239
|
+
matches_matches: ClassVar[list[Any]] = [4, 5, 8]
|
|
240
|
+
matches_mismatches: ClassVar[list[Any]] = [-2, 0, 3]
|
|
241
|
+
|
|
242
|
+
str_examples: ClassVar = [
|
|
243
|
+
("GreaterThanOrEqual(12)", GreaterThanOrEqual(12)),
|
|
244
|
+
]
|
|
245
|
+
|
|
246
|
+
describe_examples: ClassVar = [
|
|
247
|
+
("3 < 4", 3, GreaterThanOrEqual(4)),
|
|
248
|
+
("2 < 4", 2, GreaterThanOrEqual(4)),
|
|
249
|
+
]
|
|
250
|
+
|
|
251
|
+
|
|
219
252
|
class TestContainsInterface(TestCase, TestMatchersInterface):
|
|
220
|
-
matches_matcher: ClassVar = Contains("foo")
|
|
221
|
-
matches_matches: ClassVar = ["foo", "afoo", "fooa"]
|
|
222
|
-
matches_mismatches: ClassVar = ["f", "fo", "oo", "faoo", "foao"]
|
|
253
|
+
matches_matcher: ClassVar[Matcher[Any]] = Contains("foo")
|
|
254
|
+
matches_matches: ClassVar[list[Any]] = ["foo", "afoo", "fooa"]
|
|
255
|
+
matches_mismatches: ClassVar[list[Any]] = ["f", "fo", "oo", "faoo", "foao"]
|
|
223
256
|
|
|
224
257
|
str_examples: ClassVar = [
|
|
225
258
|
("Contains(1)", Contains(1)),
|
|
@@ -273,7 +306,7 @@ class StartsWithTests(TestCase):
|
|
|
273
306
|
|
|
274
307
|
def test_match(self):
|
|
275
308
|
matcher = StartsWith("bar")
|
|
276
|
-
self.
|
|
309
|
+
self.assertIsNone(matcher.match("barf"))
|
|
277
310
|
|
|
278
311
|
def test_mismatch_returns_does_not_start_with(self):
|
|
279
312
|
matcher = StartsWith("bar")
|
|
@@ -282,11 +315,15 @@ class StartsWithTests(TestCase):
|
|
|
282
315
|
def test_mismatch_sets_matchee(self):
|
|
283
316
|
matcher = StartsWith("bar")
|
|
284
317
|
mismatch = matcher.match("foo")
|
|
318
|
+
self.assertIsNotNone(mismatch)
|
|
319
|
+
assert mismatch is not None
|
|
285
320
|
self.assertEqual("foo", mismatch.matchee)
|
|
286
321
|
|
|
287
322
|
def test_mismatch_sets_expected(self):
|
|
288
323
|
matcher = StartsWith("bar")
|
|
289
324
|
mismatch = matcher.match("foo")
|
|
325
|
+
self.assertIsNotNone(mismatch)
|
|
326
|
+
assert mismatch is not None
|
|
290
327
|
self.assertEqual("bar", mismatch.expected)
|
|
291
328
|
|
|
292
329
|
|
|
@@ -343,23 +380,27 @@ class EndsWithTests(TestCase):
|
|
|
343
380
|
def test_mismatch_sets_matchee(self):
|
|
344
381
|
matcher = EndsWith("bar")
|
|
345
382
|
mismatch = matcher.match("foo")
|
|
383
|
+
self.assertIsNotNone(mismatch)
|
|
384
|
+
assert mismatch is not None
|
|
346
385
|
self.assertEqual("foo", mismatch.matchee)
|
|
347
386
|
|
|
348
387
|
def test_mismatch_sets_expected(self):
|
|
349
388
|
matcher = EndsWith("bar")
|
|
350
389
|
mismatch = matcher.match("foo")
|
|
390
|
+
self.assertIsNotNone(mismatch)
|
|
391
|
+
assert mismatch is not None
|
|
351
392
|
self.assertEqual("bar", mismatch.expected)
|
|
352
393
|
|
|
353
394
|
|
|
354
395
|
class TestSameMembers(TestCase, TestMatchersInterface):
|
|
355
|
-
matches_matcher: ClassVar = SameMembers([1, 1, 2, 3, {"foo": "bar"}])
|
|
356
|
-
matches_matches: ClassVar = [
|
|
396
|
+
matches_matcher: ClassVar[Matcher[Any]] = SameMembers([1, 1, 2, 3, {"foo": "bar"}])
|
|
397
|
+
matches_matches: ClassVar[list[Any]] = [
|
|
357
398
|
[1, 1, 2, 3, {"foo": "bar"}],
|
|
358
399
|
[3, {"foo": "bar"}, 1, 2, 1],
|
|
359
400
|
[3, 2, 1, {"foo": "bar"}, 1],
|
|
360
401
|
(2, {"foo": "bar"}, 3, 1, 1),
|
|
361
402
|
]
|
|
362
|
-
matches_mismatches: ClassVar = [
|
|
403
|
+
matches_mismatches: ClassVar[list[Any]] = [
|
|
363
404
|
{1, 2, 3},
|
|
364
405
|
[1, 1, 2, 3, 5],
|
|
365
406
|
[1, 2, 3, {"foo": "bar"}],
|
|
@@ -405,9 +446,9 @@ class TestSameMembers(TestCase, TestMatchersInterface):
|
|
|
405
446
|
|
|
406
447
|
|
|
407
448
|
class TestMatchesRegex(TestCase, TestMatchersInterface):
|
|
408
|
-
matches_matcher: ClassVar = MatchesRegex("a|b")
|
|
409
|
-
matches_matches: ClassVar = ["a", "b"]
|
|
410
|
-
matches_mismatches: ClassVar = ["c"]
|
|
449
|
+
matches_matcher: ClassVar[Matcher[Any]] = MatchesRegex("a|b")
|
|
450
|
+
matches_matches: ClassVar[list[Any]] = ["a", "b"]
|
|
451
|
+
matches_mismatches: ClassVar[list[Any]] = ["c"]
|
|
411
452
|
|
|
412
453
|
str_examples: ClassVar = [
|
|
413
454
|
("MatchesRegex('a|b')", MatchesRegex("a|b")),
|
|
@@ -430,9 +471,9 @@ class TestMatchesRegex(TestCase, TestMatchersInterface):
|
|
|
430
471
|
|
|
431
472
|
|
|
432
473
|
class TestHasLength(TestCase, TestMatchersInterface):
|
|
433
|
-
matches_matcher: ClassVar = HasLength(2)
|
|
434
|
-
matches_matches: ClassVar = [[1, 2]]
|
|
435
|
-
matches_mismatches: ClassVar = [[], [1], [3, 2, 1]]
|
|
474
|
+
matches_matcher: ClassVar[Matcher[Any]] = HasLength(2)
|
|
475
|
+
matches_matches: ClassVar[list[Any]] = [[1, 2]]
|
|
476
|
+
matches_mismatches: ClassVar[list[Any]] = [[], [1], [3, 2, 1]]
|
|
436
477
|
|
|
437
478
|
str_examples: ClassVar = [
|
|
438
479
|
("HasLength(2)", HasLength(2)),
|
|
@@ -444,9 +485,9 @@ class TestHasLength(TestCase, TestMatchersInterface):
|
|
|
444
485
|
|
|
445
486
|
|
|
446
487
|
class TestNearlyInterface(TestCase, TestMatchersInterface):
|
|
447
|
-
matches_matcher: ClassVar = Nearly(4.0, delta=0.5)
|
|
448
|
-
matches_matches: ClassVar = [4.0, 4.5, 3.5, 4.25, 3.75]
|
|
449
|
-
matches_mismatches: ClassVar = [4.51, 3.49, 5.0, 2.0, "not a number"]
|
|
488
|
+
matches_matcher: ClassVar[Matcher[Any]] = Nearly(4.0, delta=0.5)
|
|
489
|
+
matches_matches: ClassVar[list[Any]] = [4.0, 4.5, 3.5, 4.25, 3.75]
|
|
490
|
+
matches_mismatches: ClassVar[list[Any]] = [4.51, 3.49, 5.0, 2.0, "not a number"]
|
|
450
491
|
|
|
451
492
|
str_examples: ClassVar = [
|
|
452
493
|
("Nearly(4.0, delta=0.5)", Nearly(4.0, delta=0.5)),
|
|
@@ -502,6 +543,7 @@ class TestNearlyBehavior(TestCase):
|
|
|
502
543
|
matcher = Nearly(10, delta=2)
|
|
503
544
|
mismatch = matcher.match(13)
|
|
504
545
|
self.assertIsNotNone(mismatch)
|
|
546
|
+
assert mismatch is not None
|
|
505
547
|
self.assertIn("13", mismatch.describe())
|
|
506
548
|
|
|
507
549
|
def test_exact_boundary_matches(self):
|
|
@@ -541,14 +583,17 @@ class TestNearlyBehavior(TestCase):
|
|
|
541
583
|
def test_non_numeric_type_mismatch(self):
|
|
542
584
|
"""Test that non-numeric types result in a mismatch."""
|
|
543
585
|
matcher = Nearly(1.0, delta=0.1)
|
|
544
|
-
|
|
586
|
+
# intentional type mismatch
|
|
587
|
+
mismatch = matcher.match("string") # type: ignore[arg-type]
|
|
545
588
|
self.assertIsNotNone(mismatch)
|
|
589
|
+
assert mismatch is not None
|
|
546
590
|
self.assertIn("string", mismatch.describe())
|
|
547
591
|
|
|
548
592
|
def test_none_type_mismatch(self):
|
|
549
593
|
"""Test that None results in a mismatch."""
|
|
550
594
|
matcher = Nearly(1.0, delta=0.1)
|
|
551
|
-
|
|
595
|
+
# intentional type mismatch
|
|
596
|
+
mismatch = matcher.match(None) # type: ignore[arg-type]
|
|
552
597
|
self.assertIsNotNone(mismatch)
|
|
553
598
|
|
|
554
599
|
|
|
@@ -75,6 +75,8 @@ class TestKeysEqualWithList(TestCase, TestMatchersInterface):
|
|
|
75
75
|
def test_description(self):
|
|
76
76
|
matchee = {"foo": 0, "bar": 1, "baz": 2}
|
|
77
77
|
mismatch = KeysEqual("foo", "bar").match(matchee)
|
|
78
|
+
self.assertIsNotNone(mismatch)
|
|
79
|
+
assert mismatch is not None
|
|
78
80
|
description = mismatch.describe()
|
|
79
81
|
self.assertThat(
|
|
80
82
|
description,
|
|
@@ -53,6 +53,8 @@ class TestPathExists(TestCase, PathHelpers):
|
|
|
53
53
|
def test_not_exists(self):
|
|
54
54
|
doesntexist = os.path.join(self.mkdtemp(), "doesntexist")
|
|
55
55
|
mismatch = PathExists().match(doesntexist)
|
|
56
|
+
self.assertIsNotNone(mismatch)
|
|
57
|
+
assert mismatch is not None
|
|
56
58
|
self.assertThat(f"{doesntexist} does not exist.", Equals(mismatch.describe()))
|
|
57
59
|
|
|
58
60
|
|
|
@@ -63,15 +65,20 @@ class TestDirExists(TestCase, PathHelpers):
|
|
|
63
65
|
|
|
64
66
|
def test_not_exists(self):
|
|
65
67
|
doesntexist = os.path.join(self.mkdtemp(), "doesntexist")
|
|
66
|
-
|
|
67
|
-
self.
|
|
68
|
-
|
|
69
|
-
)
|
|
68
|
+
dir_mismatch = DirExists().match(doesntexist)
|
|
69
|
+
self.assertIsNotNone(dir_mismatch)
|
|
70
|
+
assert dir_mismatch is not None
|
|
71
|
+
path_mismatch = PathExists().match(doesntexist)
|
|
72
|
+
self.assertIsNotNone(path_mismatch)
|
|
73
|
+
assert path_mismatch is not None
|
|
74
|
+
self.assertThat(path_mismatch.describe(), Equals(dir_mismatch.describe()))
|
|
70
75
|
|
|
71
76
|
def test_not_a_directory(self):
|
|
72
77
|
filename = os.path.join(self.mkdtemp(), "foo")
|
|
73
78
|
self.touch(filename)
|
|
74
79
|
mismatch = DirExists().match(filename)
|
|
80
|
+
self.assertIsNotNone(mismatch)
|
|
81
|
+
assert mismatch is not None
|
|
75
82
|
self.assertThat(f"{filename} is not a directory.", Equals(mismatch.describe()))
|
|
76
83
|
|
|
77
84
|
|
|
@@ -84,14 +91,19 @@ class TestFileExists(TestCase, PathHelpers):
|
|
|
84
91
|
|
|
85
92
|
def test_not_exists(self):
|
|
86
93
|
doesntexist = os.path.join(self.mkdtemp(), "doesntexist")
|
|
87
|
-
|
|
88
|
-
self.
|
|
89
|
-
|
|
90
|
-
)
|
|
94
|
+
file_mismatch = FileExists().match(doesntexist)
|
|
95
|
+
self.assertIsNotNone(file_mismatch)
|
|
96
|
+
assert file_mismatch is not None
|
|
97
|
+
path_mismatch = PathExists().match(doesntexist)
|
|
98
|
+
self.assertIsNotNone(path_mismatch)
|
|
99
|
+
assert path_mismatch is not None
|
|
100
|
+
self.assertThat(path_mismatch.describe(), Equals(file_mismatch.describe()))
|
|
91
101
|
|
|
92
102
|
def test_not_a_file(self):
|
|
93
103
|
tempdir = self.mkdtemp()
|
|
94
104
|
mismatch = FileExists().match(tempdir)
|
|
105
|
+
self.assertIsNotNone(mismatch)
|
|
106
|
+
assert mismatch is not None
|
|
95
107
|
self.assertThat(f"{tempdir} is not a file.", Equals(mismatch.describe()))
|
|
96
108
|
|
|
97
109
|
|
|
@@ -102,10 +114,13 @@ class TestDirContains(TestCase, PathHelpers):
|
|
|
102
114
|
|
|
103
115
|
def test_not_exists(self):
|
|
104
116
|
doesntexist = os.path.join(self.mkdtemp(), "doesntexist")
|
|
105
|
-
|
|
106
|
-
self.
|
|
107
|
-
|
|
108
|
-
)
|
|
117
|
+
dir_mismatch = DirContains([]).match(doesntexist)
|
|
118
|
+
self.assertIsNotNone(dir_mismatch)
|
|
119
|
+
assert dir_mismatch is not None
|
|
120
|
+
path_mismatch = PathExists().match(doesntexist)
|
|
121
|
+
self.assertIsNotNone(path_mismatch)
|
|
122
|
+
assert path_mismatch is not None
|
|
123
|
+
self.assertThat(path_mismatch.describe(), Equals(dir_mismatch.describe()))
|
|
109
124
|
|
|
110
125
|
def test_contains_files(self):
|
|
111
126
|
tempdir = self.mkdtemp()
|
|
@@ -130,20 +145,25 @@ class TestDirContains(TestCase, PathHelpers):
|
|
|
130
145
|
def test_does_not_contain_files(self):
|
|
131
146
|
tempdir = self.mkdtemp()
|
|
132
147
|
self.touch(os.path.join(tempdir, "foo"))
|
|
133
|
-
|
|
134
|
-
self.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
)
|
|
148
|
+
mismatch_a = DirContains(["bar", "foo"]).match(tempdir)
|
|
149
|
+
self.assertIsNotNone(mismatch_a)
|
|
150
|
+
assert mismatch_a is not None
|
|
151
|
+
mismatch_b = Equals(["bar", "foo"]).match(["foo"])
|
|
152
|
+
self.assertIsNotNone(mismatch_b)
|
|
153
|
+
assert mismatch_b is not None
|
|
154
|
+
self.assertThat(mismatch_b.describe(), Equals(mismatch_a.describe()))
|
|
138
155
|
|
|
139
156
|
|
|
140
157
|
class TestFileContains(TestCase, PathHelpers):
|
|
141
158
|
def test_not_exists(self):
|
|
142
159
|
doesntexist = os.path.join(self.mkdtemp(), "doesntexist")
|
|
143
|
-
|
|
144
|
-
self.
|
|
145
|
-
|
|
146
|
-
)
|
|
160
|
+
file_mismatch = FileContains("").match(doesntexist)
|
|
161
|
+
self.assertIsNotNone(file_mismatch)
|
|
162
|
+
assert file_mismatch is not None
|
|
163
|
+
path_mismatch = PathExists().match(doesntexist)
|
|
164
|
+
self.assertIsNotNone(path_mismatch)
|
|
165
|
+
assert path_mismatch is not None
|
|
166
|
+
self.assertThat(path_mismatch.describe(), Equals(file_mismatch.describe()))
|
|
147
167
|
|
|
148
168
|
def test_contains(self):
|
|
149
169
|
tempdir = self.mkdtemp()
|
|
@@ -169,11 +189,13 @@ class TestFileContains(TestCase, PathHelpers):
|
|
|
169
189
|
tempdir = self.mkdtemp()
|
|
170
190
|
filename = os.path.join(tempdir, "foo")
|
|
171
191
|
self.create_file(filename, "Goodbye Cruel World!")
|
|
172
|
-
|
|
173
|
-
self.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
)
|
|
192
|
+
actual = FileContains("Hello World!").match(filename)
|
|
193
|
+
self.assertIsNotNone(actual)
|
|
194
|
+
assert actual is not None
|
|
195
|
+
expected = Equals("Hello World!").match("Goodbye Cruel World!")
|
|
196
|
+
self.assertIsNotNone(expected)
|
|
197
|
+
assert expected is not None
|
|
198
|
+
self.assertThat(expected.describe(), Equals(actual.describe()))
|
|
177
199
|
|
|
178
200
|
def test_binary_content(self):
|
|
179
201
|
tempdir = self.mkdtemp()
|
|
@@ -188,11 +210,13 @@ class TestFileContains(TestCase, PathHelpers):
|
|
|
188
210
|
filename = os.path.join(tempdir, "binary_file")
|
|
189
211
|
with open(filename, "wb") as f:
|
|
190
212
|
f.write(b"\x00\x01\x02")
|
|
191
|
-
|
|
192
|
-
self.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
)
|
|
213
|
+
actual = FileContains(b"\xff\xfe\xfd").match(filename)
|
|
214
|
+
self.assertIsNotNone(actual)
|
|
215
|
+
assert actual is not None
|
|
216
|
+
expected = Equals(b"\xff\xfe\xfd").match(b"\x00\x01\x02")
|
|
217
|
+
self.assertIsNotNone(expected)
|
|
218
|
+
assert expected is not None
|
|
219
|
+
self.assertThat(expected.describe(), Equals(actual.describe()))
|
|
196
220
|
|
|
197
221
|
def test_text_with_encoding(self):
|
|
198
222
|
tempdir = self.mkdtemp()
|
|
@@ -238,10 +262,13 @@ class TestTarballContains(TestCase, PathHelpers):
|
|
|
238
262
|
tarball.add(in_temp_dir("a"), "a")
|
|
239
263
|
tarball.add(in_temp_dir("b"), "b")
|
|
240
264
|
tarball.close()
|
|
241
|
-
|
|
242
|
-
self.
|
|
243
|
-
|
|
244
|
-
)
|
|
265
|
+
actual = TarballContains(["d", "c"]).match(in_temp_dir("foo.tar.gz"))
|
|
266
|
+
self.assertIsNotNone(actual)
|
|
267
|
+
assert actual is not None
|
|
268
|
+
expected = Equals(["c", "d"]).match(["a", "b"])
|
|
269
|
+
self.assertIsNotNone(expected)
|
|
270
|
+
assert expected is not None
|
|
271
|
+
self.assertEqual(actual.describe(), expected.describe())
|
|
245
272
|
|
|
246
273
|
|
|
247
274
|
class TestSamePath(TestCase, PathHelpers):
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from typing import ClassVar
|
|
4
4
|
|
|
5
5
|
from testtools import TestCase
|
|
6
|
+
from testtools.content import text_content
|
|
6
7
|
from testtools.matchers import (
|
|
7
8
|
DocTestMatches,
|
|
8
9
|
Equals,
|
|
@@ -192,7 +193,7 @@ class TestAnnotate(TestCase, TestMatchersInterface):
|
|
|
192
193
|
matcher = Equals(1)
|
|
193
194
|
expected = Annotate("foo", matcher)
|
|
194
195
|
annotated = Annotate.if_message("foo", matcher)
|
|
195
|
-
self.assertThat(
|
|
196
|
+
self.assertThat( # type: ignore[misc]
|
|
196
197
|
annotated, MatchesStructure.fromExample(expected, "annotation", "matcher")
|
|
197
198
|
)
|
|
198
199
|
|
|
@@ -201,7 +202,7 @@ class TestAnnotatedMismatch(TestCase):
|
|
|
201
202
|
run_tests_with = FullStackRunTest
|
|
202
203
|
|
|
203
204
|
def test_forwards_details(self):
|
|
204
|
-
x = Mismatch("description", {"foo": "bar"})
|
|
205
|
+
x = Mismatch("description", {"foo": text_content("bar")})
|
|
205
206
|
annotated = AnnotatedMismatch("annotation", x)
|
|
206
207
|
self.assertEqual(x.get_details(), annotated.get_details())
|
|
207
208
|
|
|
@@ -9,6 +9,7 @@ from testtools import (
|
|
|
9
9
|
from testtools.compat import (
|
|
10
10
|
text_repr,
|
|
11
11
|
)
|
|
12
|
+
from testtools.content import text_content
|
|
12
13
|
from testtools.matchers import (
|
|
13
14
|
Equals,
|
|
14
15
|
MatchesException,
|
|
@@ -30,9 +31,10 @@ class TestMismatch(TestCase):
|
|
|
30
31
|
run_tests_with = FullStackRunTest
|
|
31
32
|
|
|
32
33
|
def test_constructor_arguments(self):
|
|
33
|
-
|
|
34
|
+
detail = text_content("things")
|
|
35
|
+
mismatch = Mismatch("some description", {"detail": detail})
|
|
34
36
|
self.assertEqual("some description", mismatch.describe())
|
|
35
|
-
self.assertEqual({"detail":
|
|
37
|
+
self.assertEqual({"detail": detail}, mismatch.get_details())
|
|
36
38
|
|
|
37
39
|
def test_constructor_no_arguments(self):
|
|
38
40
|
mismatch = Mismatch()
|
|
@@ -47,12 +49,17 @@ class TestMismatchError(TestCase):
|
|
|
47
49
|
# MismatchError is an AssertionError, so that most of the time, it
|
|
48
50
|
# looks like a test failure, rather than an error.
|
|
49
51
|
def raise_mismatch_error():
|
|
50
|
-
|
|
52
|
+
mismatch = Equals(3).match(2)
|
|
53
|
+
self.assertIsNotNone(mismatch)
|
|
54
|
+
assert mismatch is not None
|
|
55
|
+
raise MismatchError(2, Equals(3), mismatch)
|
|
51
56
|
|
|
52
57
|
self.assertRaises(AssertionError, raise_mismatch_error)
|
|
53
58
|
|
|
54
59
|
def test_default_description_is_mismatch(self):
|
|
55
60
|
mismatch = Equals(3).match(2)
|
|
61
|
+
self.assertIsNotNone(mismatch)
|
|
62
|
+
assert mismatch is not None
|
|
56
63
|
e = MismatchError(2, Equals(3), mismatch)
|
|
57
64
|
self.assertEqual(mismatch.describe(), str(e))
|
|
58
65
|
|
|
@@ -60,17 +67,21 @@ class TestMismatchError(TestCase):
|
|
|
60
67
|
matchee = "\xa7"
|
|
61
68
|
matcher = Equals("a")
|
|
62
69
|
mismatch = matcher.match(matchee)
|
|
70
|
+
self.assertIsNotNone(mismatch)
|
|
71
|
+
assert mismatch is not None
|
|
63
72
|
e = MismatchError(matchee, matcher, mismatch)
|
|
64
73
|
self.assertEqual(mismatch.describe(), str(e))
|
|
65
74
|
|
|
66
75
|
def test_verbose_description(self):
|
|
67
76
|
matchee = 2
|
|
68
77
|
matcher = Equals(3)
|
|
69
|
-
mismatch = matcher.match(
|
|
78
|
+
mismatch = matcher.match(matchee)
|
|
79
|
+
self.assertIsNotNone(mismatch)
|
|
80
|
+
assert mismatch is not None
|
|
70
81
|
e = MismatchError(matchee, matcher, mismatch, True)
|
|
71
82
|
expected = (
|
|
72
83
|
f"Match failed. Matchee: {matchee!r}\nMatcher: {matcher}\n"
|
|
73
|
-
f"Difference: {
|
|
84
|
+
f"Difference: {mismatch.describe()}\n"
|
|
74
85
|
)
|
|
75
86
|
self.assertEqual(expected, str(e))
|
|
76
87
|
|
|
@@ -80,6 +91,8 @@ class TestMismatchError(TestCase):
|
|
|
80
91
|
matchee = "\xa7"
|
|
81
92
|
matcher = Equals("a")
|
|
82
93
|
mismatch = matcher.match(matchee)
|
|
94
|
+
self.assertIsNotNone(mismatch)
|
|
95
|
+
assert mismatch is not None
|
|
83
96
|
expected = (
|
|
84
97
|
f"Match failed. Matchee: {text_repr(matchee)}\nMatcher: {matcher}\n"
|
|
85
98
|
f"Difference: {mismatch.describe()}\n"
|
|
@@ -92,17 +105,17 @@ class TestMismatchDecorator(TestCase):
|
|
|
92
105
|
run_tests_with = FullStackRunTest
|
|
93
106
|
|
|
94
107
|
def test_forwards_description(self):
|
|
95
|
-
x = Mismatch("description", {"foo": "bar"})
|
|
108
|
+
x = Mismatch("description", {"foo": text_content("bar")})
|
|
96
109
|
decorated = MismatchDecorator(x)
|
|
97
110
|
self.assertEqual(x.describe(), decorated.describe())
|
|
98
111
|
|
|
99
112
|
def test_forwards_details(self):
|
|
100
|
-
x = Mismatch("description", {"foo": "bar"})
|
|
113
|
+
x = Mismatch("description", {"foo": text_content("bar")})
|
|
101
114
|
decorated = MismatchDecorator(x)
|
|
102
115
|
self.assertEqual(x.get_details(), decorated.get_details())
|
|
103
116
|
|
|
104
117
|
def test_repr(self):
|
|
105
|
-
x = Mismatch("description", {"foo": "bar"})
|
|
118
|
+
x = Mismatch("description", {"foo": text_content("bar")})
|
|
106
119
|
decorated = MismatchDecorator(x)
|
|
107
120
|
self.assertEqual(
|
|
108
121
|
f"<testtools.matchers.MismatchDecorator({x!r})>", repr(decorated)
|