testtools 2.8.5__tar.gz → 2.9.0__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.
Files changed (110) hide show
  1. {testtools-2.8.5 → testtools-2.9.0}/NEWS +49 -2
  2. {testtools-2.8.5 → testtools-2.9.0}/PKG-INFO +3 -3
  3. {testtools-2.8.5 → testtools-2.9.0}/README.rst +1 -1
  4. {testtools-2.8.5 → testtools-2.9.0}/doc/for-test-authors.rst +3 -1
  5. {testtools-2.8.5 → testtools-2.9.0}/pyproject.toml +5 -5
  6. {testtools-2.8.5 → testtools-2.9.0}/tests/helpers.py +2 -1
  7. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_basic.py +82 -37
  8. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_dict.py +2 -0
  9. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_filesystem.py +62 -35
  10. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_higherorder.py +3 -2
  11. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_impl.py +21 -8
  12. {testtools-2.8.5 → testtools-2.9.0}/tests/test_assert_that.py +27 -13
  13. {testtools-2.8.5 → testtools-2.9.0}/tests/test_content.py +7 -2
  14. {testtools-2.8.5 → testtools-2.9.0}/tests/test_content_type.py +6 -4
  15. {testtools-2.8.5 → testtools-2.9.0}/tests/test_fixturesupport.py +1 -1
  16. {testtools-2.8.5 → testtools-2.9.0}/tests/test_run.py +5 -3
  17. {testtools-2.8.5 → testtools-2.9.0}/tests/test_testcase.py +49 -34
  18. {testtools-2.8.5 → testtools-2.9.0}/tests/test_testresult.py +68 -37
  19. {testtools-2.8.5 → testtools-2.9.0}/tests/test_testsuite.py +22 -7
  20. {testtools-2.8.5 → testtools-2.9.0}/tests/test_with_with.py +3 -1
  21. testtools-2.9.0/tests/twistedsupport/__init__.py +33 -0
  22. {testtools-2.8.5 → testtools-2.9.0}/tests/twistedsupport/test_matchers.py +4 -1
  23. {testtools-2.8.5 → testtools-2.9.0}/tests/twistedsupport/test_runtest.py +10 -10
  24. testtools-2.9.0/testtools/_types.py +8 -0
  25. {testtools-2.8.5 → testtools-2.9.0}/testtools/_version.py +2 -2
  26. {testtools-2.8.5 → testtools-2.9.0}/testtools/compat.py +11 -1
  27. {testtools-2.8.5 → testtools-2.9.0}/testtools/content.py +2 -2
  28. {testtools-2.8.5 → testtools-2.9.0}/testtools/content_type.py +4 -0
  29. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/__init__.py +4 -0
  30. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_basic.py +63 -44
  31. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_datastructures.py +3 -3
  32. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_dict.py +2 -2
  33. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_doctest.py +2 -2
  34. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_exception.py +12 -16
  35. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_filesystem.py +2 -2
  36. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_warnings.py +1 -1
  37. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/test.py +15 -17
  38. {testtools-2.8.5 → testtools-2.9.0}/testtools/monkey.py +7 -2
  39. {testtools-2.8.5 → testtools-2.9.0}/testtools/run.py +29 -85
  40. {testtools-2.8.5 → testtools-2.9.0}/testtools/runtest.py +3 -3
  41. {testtools-2.8.5 → testtools-2.9.0}/testtools/testcase.py +178 -110
  42. {testtools-2.8.5 → testtools-2.9.0}/testtools/testresult/__init__.py +0 -2
  43. {testtools-2.8.5 → testtools-2.9.0}/testtools/testresult/doubles.py +7 -12
  44. {testtools-2.8.5 → testtools-2.9.0}/testtools/testresult/real.py +58 -62
  45. {testtools-2.8.5 → testtools-2.9.0}/testtools/testsuite.py +12 -13
  46. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/_matchers.py +6 -4
  47. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/_runtest.py +1 -4
  48. {testtools-2.8.5 → testtools-2.9.0}/tox.ini +1 -1
  49. testtools-2.8.5/tests/twistedsupport/__init__.py +0 -21
  50. {testtools-2.8.5 → testtools-2.9.0}/.git-blame-ignore-revs +0 -0
  51. {testtools-2.8.5 → testtools-2.9.0}/.github/dependabot.yaml +0 -0
  52. {testtools-2.8.5 → testtools-2.9.0}/.github/workflows/publish.yml +0 -0
  53. {testtools-2.8.5 → testtools-2.9.0}/.github/workflows/test.yml +0 -0
  54. {testtools-2.8.5 → testtools-2.9.0}/.gitignore +0 -0
  55. {testtools-2.8.5 → testtools-2.9.0}/.gitreview +0 -0
  56. {testtools-2.8.5 → testtools-2.9.0}/.testr.conf +0 -0
  57. {testtools-2.8.5 → testtools-2.9.0}/LICENSE +0 -0
  58. {testtools-2.8.5 → testtools-2.9.0}/MANIFEST.in +0 -0
  59. {testtools-2.8.5 → testtools-2.9.0}/Makefile +0 -0
  60. {testtools-2.8.5 → testtools-2.9.0}/disperse.conf +0 -0
  61. {testtools-2.8.5 → testtools-2.9.0}/doc/Makefile +0 -0
  62. {testtools-2.8.5 → testtools-2.9.0}/doc/_static/placeholder.txt +0 -0
  63. {testtools-2.8.5 → testtools-2.9.0}/doc/_templates/placeholder.txt +0 -0
  64. {testtools-2.8.5 → testtools-2.9.0}/doc/api.rst +0 -0
  65. {testtools-2.8.5 → testtools-2.9.0}/doc/conf.py +0 -0
  66. {testtools-2.8.5 → testtools-2.9.0}/doc/for-framework-folk.rst +0 -0
  67. {testtools-2.8.5 → testtools-2.9.0}/doc/hacking.rst +0 -0
  68. {testtools-2.8.5 → testtools-2.9.0}/doc/index.rst +0 -0
  69. {testtools-2.8.5 → testtools-2.9.0}/doc/make.bat +0 -0
  70. {testtools-2.8.5 → testtools-2.9.0}/doc/news.rst +0 -0
  71. {testtools-2.8.5 → testtools-2.9.0}/doc/overview.rst +0 -0
  72. {testtools-2.8.5 → testtools-2.9.0}/doc/twisted-support.rst +0 -0
  73. {testtools-2.8.5 → testtools-2.9.0}/readthedocs-requirements.txt +0 -0
  74. {testtools-2.8.5 → testtools-2.9.0}/requirements.txt +0 -0
  75. {testtools-2.8.5 → testtools-2.9.0}/scripts/README +0 -0
  76. {testtools-2.8.5 → testtools-2.9.0}/scripts/all-pythons +0 -0
  77. {testtools-2.8.5 → testtools-2.9.0}/scripts/update-rtfd +0 -0
  78. {testtools-2.8.5 → testtools-2.9.0}/tests/__init__.py +0 -0
  79. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/__init__.py +0 -0
  80. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_const.py +0 -0
  81. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_datastructures.py +0 -0
  82. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_doctest.py +0 -0
  83. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_exception.py +0 -0
  84. {testtools-2.8.5 → testtools-2.9.0}/tests/matchers/test_warnings.py +0 -0
  85. {testtools-2.8.5 → testtools-2.9.0}/tests/samplecases.py +0 -0
  86. {testtools-2.8.5 → testtools-2.9.0}/tests/test_compat.py +0 -0
  87. {testtools-2.8.5 → testtools-2.9.0}/tests/test_helpers.py +0 -0
  88. {testtools-2.8.5 → testtools-2.9.0}/tests/test_monkey.py +0 -0
  89. {testtools-2.8.5 → testtools-2.9.0}/tests/test_runtest.py +0 -0
  90. {testtools-2.8.5 → testtools-2.9.0}/tests/test_tags.py +0 -0
  91. {testtools-2.8.5 → testtools-2.9.0}/tests/twistedsupport/_helpers.py +0 -0
  92. {testtools-2.8.5 → testtools-2.9.0}/tests/twistedsupport/test_deferred.py +0 -0
  93. {testtools-2.8.5 → testtools-2.9.0}/tests/twistedsupport/test_spinner.py +0 -0
  94. {testtools-2.8.5 → testtools-2.9.0}/testtools/__init__.py +0 -0
  95. {testtools-2.8.5 → testtools-2.9.0}/testtools/_version.pyi +0 -0
  96. {testtools-2.8.5 → testtools-2.9.0}/testtools/assertions.py +0 -0
  97. {testtools-2.8.5 → testtools-2.9.0}/testtools/helpers.py +0 -0
  98. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_const.py +0 -0
  99. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_higherorder.py +0 -0
  100. {testtools-2.8.5 → testtools-2.9.0}/testtools/matchers/_impl.py +0 -0
  101. {testtools-2.8.5 → testtools-2.9.0}/testtools/py.typed +0 -0
  102. {testtools-2.8.5 → testtools-2.9.0}/testtools/tags.py +0 -0
  103. {testtools-2.8.5 → testtools-2.9.0}/testtools/tests/__init__.py +0 -0
  104. {testtools-2.8.5 → testtools-2.9.0}/testtools/tests/helpers.py +0 -0
  105. {testtools-2.8.5 → testtools-2.9.0}/testtools/tests/matchers/__init__.py +0 -0
  106. {testtools-2.8.5 → testtools-2.9.0}/testtools/tests/matchers/helpers.py +0 -0
  107. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/__init__.py +0 -0
  108. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/_deferred.py +0 -0
  109. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/_deferreddebug.py +0 -0
  110. {testtools-2.8.5 → testtools-2.9.0}/testtools/twistedsupport/_spinner.py +0 -0
@@ -3,6 +3,54 @@ testtools NEWS
3
3
 
4
4
  Changes and improvements to testtools_, grouped by release.
5
5
 
6
+ NEXT
7
+ ~~~~
8
+
9
+ 2.9.0
10
+ ~~~~~
11
+
12
+ Improvements
13
+ ------------
14
+ * Add ``LessThanOrEqual`` and ``GreaterThanOrEqual`` matchers.
15
+ (Julian Edwards, #594)
16
+
17
+ * Improve type annotations throughout the codebase, including compatibility
18
+ fixes for mypy 1.20.0.
19
+ (Stephen Finucane, #587, #591, #592, #593, #600)
20
+
21
+ 2.8.7
22
+ ~~~~~
23
+
24
+ Improvements
25
+ ------------
26
+ * Fix an issue with ``iterate_tests``, which was recently changes to insist
27
+ on accepting an instance of ``unittest.TestSuite``, breaking some users.
28
+ (Jelmer Vernooij, #584)
29
+
30
+ * Improve the type annotations for ``testtools.testcase.TestCase.skipTest``
31
+ (Stephen Finucane, #585)
32
+
33
+ * Correct a URL in the README
34
+ (Steve Kowalik, #582)
35
+
36
+ 2.8.6
37
+ ~~~~~
38
+
39
+ Improvements
40
+ ------------
41
+ * Improve the type annotations for ``testtools.testcase.TestCase.assertRaises``.
42
+ This method will now be typed correctly when called as a method or as a
43
+ context manager.
44
+ (Stephen Finucane, #577, #578)
45
+
46
+ 2.8.5
47
+ ~~~~~
48
+
49
+ Improvements
50
+ ------------
51
+ * Fix the type annotations for ``testtools.testcase.TestCase.useFixture``
52
+ (Stephen Finucane, #574)
53
+
6
54
  2.8.4
7
55
  ~~~~~
8
56
 
@@ -70,8 +118,7 @@ Improvements
70
118
  (Jelmer Vernooij, #538)
71
119
 
72
120
  * Allow stream=None to be passed to various TestResult
73
- classes that now support verbosity; fixes a regression
74
- from 2.8.0.
121
+ classes that now support verbosity; fixes a regression from 2.8.0.
75
122
  (Jelmer Vernooij)
76
123
 
77
124
  2.8.1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testtools
3
- Version: 2.8.5
3
+ Version: 2.9.0
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.0.0; extra == 'dev'
29
- Requires-Dist: ruff==0.15.2; extra == 'dev'
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'
@@ -51,7 +51,7 @@ If you would like to use our Twisted support, then you will need the
51
51
  ``testtools[twisted]`` extra.
52
52
 
53
53
  If you want to use ``fixtures`` then you can either install fixtures (e.g. from
54
- https://github.com/testing-cabalfixtures or https://pypi.python.org/pypi/fixtures)
54
+ https://github.com/testing-cabal/fixtures or https://pypi.python.org/pypi/fixtures)
55
55
  or alternatively just make sure your fixture objects obey the same protocol.
56
56
 
57
57
 
@@ -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
- class IsDivisibleBy(object):
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.2",
41
- "mypy>=1.0.0",
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 is here temporarily due to the rapid changes in typing across
67
- # dependencies
68
- warn_unused_ignores = false
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.assertIs(None, matcher.match("barf"))
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
- mismatch = matcher.match("string")
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
- mismatch = matcher.match(None)
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
- mismatch = DirExists().match(doesntexist)
67
- self.assertThat(
68
- PathExists().match(doesntexist).describe(), Equals(mismatch.describe())
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
- mismatch = FileExists().match(doesntexist)
88
- self.assertThat(
89
- PathExists().match(doesntexist).describe(), Equals(mismatch.describe())
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
- mismatch = DirContains([]).match(doesntexist)
106
- self.assertThat(
107
- PathExists().match(doesntexist).describe(), Equals(mismatch.describe())
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
- mismatch = DirContains(["bar", "foo"]).match(tempdir)
134
- self.assertThat(
135
- Equals(["bar", "foo"]).match(["foo"]).describe(),
136
- Equals(mismatch.describe()),
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
- mismatch = FileContains("").match(doesntexist)
144
- self.assertThat(
145
- PathExists().match(doesntexist).describe(), Equals(mismatch.describe())
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
- mismatch = FileContains("Hello World!").match(filename)
173
- self.assertThat(
174
- Equals("Hello World!").match("Goodbye Cruel World!").describe(),
175
- Equals(mismatch.describe()),
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
- mismatch = FileContains(b"\xff\xfe\xfd").match(filename)
192
- self.assertThat(
193
- Equals(b"\xff\xfe\xfd").match(b"\x00\x01\x02").describe(),
194
- Equals(mismatch.describe()),
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
- mismatch = TarballContains(["d", "c"]).match(in_temp_dir("foo.tar.gz"))
242
- self.assertEqual(
243
- mismatch.describe(), Equals(["c", "d"]).match(["a", "b"]).describe()
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