testtools 2.8.5__tar.gz → 2.8.7__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 (108) hide show
  1. {testtools-2.8.5 → testtools-2.8.7}/NEWS +37 -2
  2. {testtools-2.8.5 → testtools-2.8.7}/PKG-INFO +2 -2
  3. {testtools-2.8.5 → testtools-2.8.7}/README.rst +1 -1
  4. {testtools-2.8.5 → testtools-2.8.7}/pyproject.toml +1 -1
  5. {testtools-2.8.5 → testtools-2.8.7}/tests/test_testsuite.py +17 -0
  6. {testtools-2.8.5 → testtools-2.8.7}/testtools/_version.py +2 -2
  7. {testtools-2.8.5 → testtools-2.8.7}/testtools/testcase.py +46 -16
  8. {testtools-2.8.5 → testtools-2.8.7}/testtools/testsuite.py +4 -4
  9. {testtools-2.8.5 → testtools-2.8.7}/.git-blame-ignore-revs +0 -0
  10. {testtools-2.8.5 → testtools-2.8.7}/.github/dependabot.yaml +0 -0
  11. {testtools-2.8.5 → testtools-2.8.7}/.github/workflows/publish.yml +0 -0
  12. {testtools-2.8.5 → testtools-2.8.7}/.github/workflows/test.yml +0 -0
  13. {testtools-2.8.5 → testtools-2.8.7}/.gitignore +0 -0
  14. {testtools-2.8.5 → testtools-2.8.7}/.gitreview +0 -0
  15. {testtools-2.8.5 → testtools-2.8.7}/.testr.conf +0 -0
  16. {testtools-2.8.5 → testtools-2.8.7}/LICENSE +0 -0
  17. {testtools-2.8.5 → testtools-2.8.7}/MANIFEST.in +0 -0
  18. {testtools-2.8.5 → testtools-2.8.7}/Makefile +0 -0
  19. {testtools-2.8.5 → testtools-2.8.7}/disperse.conf +0 -0
  20. {testtools-2.8.5 → testtools-2.8.7}/doc/Makefile +0 -0
  21. {testtools-2.8.5 → testtools-2.8.7}/doc/_static/placeholder.txt +0 -0
  22. {testtools-2.8.5 → testtools-2.8.7}/doc/_templates/placeholder.txt +0 -0
  23. {testtools-2.8.5 → testtools-2.8.7}/doc/api.rst +0 -0
  24. {testtools-2.8.5 → testtools-2.8.7}/doc/conf.py +0 -0
  25. {testtools-2.8.5 → testtools-2.8.7}/doc/for-framework-folk.rst +0 -0
  26. {testtools-2.8.5 → testtools-2.8.7}/doc/for-test-authors.rst +0 -0
  27. {testtools-2.8.5 → testtools-2.8.7}/doc/hacking.rst +0 -0
  28. {testtools-2.8.5 → testtools-2.8.7}/doc/index.rst +0 -0
  29. {testtools-2.8.5 → testtools-2.8.7}/doc/make.bat +0 -0
  30. {testtools-2.8.5 → testtools-2.8.7}/doc/news.rst +0 -0
  31. {testtools-2.8.5 → testtools-2.8.7}/doc/overview.rst +0 -0
  32. {testtools-2.8.5 → testtools-2.8.7}/doc/twisted-support.rst +0 -0
  33. {testtools-2.8.5 → testtools-2.8.7}/readthedocs-requirements.txt +0 -0
  34. {testtools-2.8.5 → testtools-2.8.7}/requirements.txt +0 -0
  35. {testtools-2.8.5 → testtools-2.8.7}/scripts/README +0 -0
  36. {testtools-2.8.5 → testtools-2.8.7}/scripts/all-pythons +0 -0
  37. {testtools-2.8.5 → testtools-2.8.7}/scripts/update-rtfd +0 -0
  38. {testtools-2.8.5 → testtools-2.8.7}/tests/__init__.py +0 -0
  39. {testtools-2.8.5 → testtools-2.8.7}/tests/helpers.py +0 -0
  40. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/__init__.py +0 -0
  41. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_basic.py +0 -0
  42. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_const.py +0 -0
  43. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_datastructures.py +0 -0
  44. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_dict.py +0 -0
  45. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_doctest.py +0 -0
  46. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_exception.py +0 -0
  47. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_filesystem.py +0 -0
  48. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_higherorder.py +0 -0
  49. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_impl.py +0 -0
  50. {testtools-2.8.5 → testtools-2.8.7}/tests/matchers/test_warnings.py +0 -0
  51. {testtools-2.8.5 → testtools-2.8.7}/tests/samplecases.py +0 -0
  52. {testtools-2.8.5 → testtools-2.8.7}/tests/test_assert_that.py +0 -0
  53. {testtools-2.8.5 → testtools-2.8.7}/tests/test_compat.py +0 -0
  54. {testtools-2.8.5 → testtools-2.8.7}/tests/test_content.py +0 -0
  55. {testtools-2.8.5 → testtools-2.8.7}/tests/test_content_type.py +0 -0
  56. {testtools-2.8.5 → testtools-2.8.7}/tests/test_fixturesupport.py +0 -0
  57. {testtools-2.8.5 → testtools-2.8.7}/tests/test_helpers.py +0 -0
  58. {testtools-2.8.5 → testtools-2.8.7}/tests/test_monkey.py +0 -0
  59. {testtools-2.8.5 → testtools-2.8.7}/tests/test_run.py +0 -0
  60. {testtools-2.8.5 → testtools-2.8.7}/tests/test_runtest.py +0 -0
  61. {testtools-2.8.5 → testtools-2.8.7}/tests/test_tags.py +0 -0
  62. {testtools-2.8.5 → testtools-2.8.7}/tests/test_testcase.py +0 -0
  63. {testtools-2.8.5 → testtools-2.8.7}/tests/test_testresult.py +0 -0
  64. {testtools-2.8.5 → testtools-2.8.7}/tests/test_with_with.py +0 -0
  65. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/__init__.py +0 -0
  66. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/_helpers.py +0 -0
  67. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/test_deferred.py +0 -0
  68. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/test_matchers.py +0 -0
  69. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/test_runtest.py +0 -0
  70. {testtools-2.8.5 → testtools-2.8.7}/tests/twistedsupport/test_spinner.py +0 -0
  71. {testtools-2.8.5 → testtools-2.8.7}/testtools/__init__.py +0 -0
  72. {testtools-2.8.5 → testtools-2.8.7}/testtools/_version.pyi +0 -0
  73. {testtools-2.8.5 → testtools-2.8.7}/testtools/assertions.py +0 -0
  74. {testtools-2.8.5 → testtools-2.8.7}/testtools/compat.py +0 -0
  75. {testtools-2.8.5 → testtools-2.8.7}/testtools/content.py +0 -0
  76. {testtools-2.8.5 → testtools-2.8.7}/testtools/content_type.py +0 -0
  77. {testtools-2.8.5 → testtools-2.8.7}/testtools/helpers.py +0 -0
  78. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/__init__.py +0 -0
  79. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_basic.py +0 -0
  80. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_const.py +0 -0
  81. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_datastructures.py +0 -0
  82. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_dict.py +0 -0
  83. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_doctest.py +0 -0
  84. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_exception.py +0 -0
  85. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_filesystem.py +0 -0
  86. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_higherorder.py +0 -0
  87. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_impl.py +0 -0
  88. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/_warnings.py +0 -0
  89. {testtools-2.8.5 → testtools-2.8.7}/testtools/matchers/test.py +0 -0
  90. {testtools-2.8.5 → testtools-2.8.7}/testtools/monkey.py +0 -0
  91. {testtools-2.8.5 → testtools-2.8.7}/testtools/py.typed +0 -0
  92. {testtools-2.8.5 → testtools-2.8.7}/testtools/run.py +0 -0
  93. {testtools-2.8.5 → testtools-2.8.7}/testtools/runtest.py +0 -0
  94. {testtools-2.8.5 → testtools-2.8.7}/testtools/tags.py +0 -0
  95. {testtools-2.8.5 → testtools-2.8.7}/testtools/testresult/__init__.py +0 -0
  96. {testtools-2.8.5 → testtools-2.8.7}/testtools/testresult/doubles.py +0 -0
  97. {testtools-2.8.5 → testtools-2.8.7}/testtools/testresult/real.py +0 -0
  98. {testtools-2.8.5 → testtools-2.8.7}/testtools/tests/__init__.py +0 -0
  99. {testtools-2.8.5 → testtools-2.8.7}/testtools/tests/helpers.py +0 -0
  100. {testtools-2.8.5 → testtools-2.8.7}/testtools/tests/matchers/__init__.py +0 -0
  101. {testtools-2.8.5 → testtools-2.8.7}/testtools/tests/matchers/helpers.py +0 -0
  102. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/__init__.py +0 -0
  103. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/_deferred.py +0 -0
  104. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/_deferreddebug.py +0 -0
  105. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/_matchers.py +0 -0
  106. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/_runtest.py +0 -0
  107. {testtools-2.8.5 → testtools-2.8.7}/testtools/twistedsupport/_spinner.py +0 -0
  108. {testtools-2.8.5 → testtools-2.8.7}/tox.ini +0 -0
@@ -3,6 +3,42 @@ testtools NEWS
3
3
 
4
4
  Changes and improvements to testtools_, grouped by release.
5
5
 
6
+ NEXT
7
+ ~~~~
8
+
9
+ 2.8.7
10
+ ~~~~~
11
+
12
+ Improvements
13
+ ------------
14
+ * Fix an issue with ``iterate_tests``, which was recently changes to insist
15
+ on accepting an instance of ``unittest.TestSuite``, breaking some users.
16
+ (Jelmer Vernooij, #584)
17
+
18
+ * Improve the type annotations for ``testtools.testcase.TestCase.skipTest``
19
+ (Stephen Finucane, #585)
20
+
21
+ * Correct a URL in the README
22
+ (Steve Kowalik, #582)
23
+
24
+ 2.8.6
25
+ ~~~~~
26
+
27
+ Improvements
28
+ ------------
29
+ * Improve the type annotations for ``testtools.testcase.TestCase.assertRaises``.
30
+ This method will now be typed correctly when called as a method or as a
31
+ context manager.
32
+ (Stephen Finucane, #577, #578)
33
+
34
+ 2.8.5
35
+ ~~~~~
36
+
37
+ Improvements
38
+ ------------
39
+ * Fix the type annotations for ``testtools.testcase.TestCase.useFixture``
40
+ (Stephen Finucane, #574)
41
+
6
42
  2.8.4
7
43
  ~~~~~
8
44
 
@@ -70,8 +106,7 @@ Improvements
70
106
  (Jelmer Vernooij, #538)
71
107
 
72
108
  * Allow stream=None to be passed to various TestResult
73
- classes that now support verbosity; fixes a regression
74
- from 2.8.0.
109
+ classes that now support verbosity; fixes a regression from 2.8.0.
75
110
  (Jelmer Vernooij)
76
111
 
77
112
  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.8.7
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>
@@ -26,7 +26,7 @@ Classifier: Typing :: Typed
26
26
  Requires-Python: >=3.10
27
27
  Provides-Extra: dev
28
28
  Requires-Dist: mypy>=1.0.0; extra == 'dev'
29
- Requires-Dist: ruff==0.15.2; extra == 'dev'
29
+ Requires-Dist: ruff==0.15.5; 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
 
@@ -37,7 +37,7 @@ 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",
40
+ "ruff==0.15.5",
41
41
  "mypy>=1.0.0",
42
42
  "typing-extensions;python_version<'3.11'",
43
43
  ]
@@ -387,6 +387,23 @@ class TestFixtureSuite(TestCase):
387
387
  self.assertRaises(ValueError, suite.sort_tests)
388
388
 
389
389
 
390
+ class TestIterateTests(TestCase):
391
+ def test_iterate_suite(self):
392
+ a = PlaceHolder("a")
393
+ b = PlaceHolder("b")
394
+ suite = unittest.TestSuite([a, b]) # type: ignore[list-item]
395
+ self.assertEqual([a, b], list(iterate_tests(suite)))
396
+
397
+ def test_iterate_single_test(self):
398
+ a = PlaceHolder("a")
399
+ self.assertEqual([a], list(iterate_tests(a)))
400
+
401
+ def test_iterate_list(self):
402
+ a = PlaceHolder("a")
403
+ b = PlaceHolder("b")
404
+ self.assertEqual([a, b], list(iterate_tests([a, b])))
405
+
406
+
390
407
  class TestSortedTests(TestCase):
391
408
  def test_sorts_custom_suites(self):
392
409
  a = PlaceHolder("a")
@@ -1,3 +1,3 @@
1
1
  # This file is automatically generated by hatch.
2
- version = '2.8.5'
3
- __version__ = (2, 8, 5)
2
+ version = '2.8.7'
3
+ __version__ = (2, 8, 7)
@@ -23,7 +23,7 @@ import sys
23
23
  import types
24
24
  import unittest
25
25
  from collections.abc import Callable, Iterator
26
- from typing import TypeVar, cast
26
+ from typing import TYPE_CHECKING, NoReturn, ParamSpec, TypeVar, cast, overload
27
27
  from unittest.case import SkipTest
28
28
 
29
29
  T = TypeVar("T")
@@ -56,6 +56,12 @@ from testtools.testresult import (
56
56
  TestResult,
57
57
  )
58
58
 
59
+ if TYPE_CHECKING:
60
+ if sys.version_info >= (3, 11):
61
+ from typing import Self
62
+ else:
63
+ from typing_extensions import Self
64
+
59
65
  # Circular import: fixtures imports gather_details from here, we import
60
66
  # fixtures, leading to gather_details not being available and fixtures being
61
67
  # unable to import it.
@@ -82,6 +88,8 @@ class _ExpectedFailure(Exception):
82
88
 
83
89
 
84
90
  # TypeVar for decorators
91
+ _P = ParamSpec("_P")
92
+ _R = TypeVar("_R")
85
93
  _F = TypeVar("_F", bound=Callable[..., object])
86
94
 
87
95
 
@@ -358,7 +366,7 @@ class TestCase(unittest.TestCase):
358
366
  def shortDescription(self) -> str:
359
367
  return self.id()
360
368
 
361
- def skipTest(self, reason: str) -> None: # type: ignore[override]
369
+ def skipTest(self, reason: str) -> NoReturn:
362
370
  """Cause this test to be skipped.
363
371
 
364
372
  This raises self.skipException(reason). skipException is raised
@@ -384,10 +392,10 @@ class TestCase(unittest.TestCase):
384
392
 
385
393
  def addCleanup(
386
394
  self,
387
- function: Callable[..., object],
395
+ function: Callable[_P, _R],
388
396
  /,
389
- *arguments: object,
390
- **keywordArguments: object,
397
+ *args: _P.args,
398
+ **kwargs: _P.kwargs,
391
399
  ) -> None:
392
400
  """Add a cleanup function to be called after tearDown.
393
401
 
@@ -401,7 +409,7 @@ class TestCase(unittest.TestCase):
401
409
  Cleanup functions are always called before a test finishes running,
402
410
  even if setUp is aborted by an exception.
403
411
  """
404
- self._cleanups.append((function, arguments, keywordArguments))
412
+ self._cleanups.append((function, args, kwargs))
405
413
 
406
414
  def addOnException(self, handler: "Callable[[ExcInfo], None]") -> None:
407
415
  """Add a handler to be called when an exception occurs in test code.
@@ -493,12 +501,28 @@ class TestCase(unittest.TestCase):
493
501
  matcher = IsInstance(klass)
494
502
  self.assertThat(obj, matcher, msg or "")
495
503
 
504
+ @overload # type: ignore[override]
505
+ def assertRaises(
506
+ self,
507
+ expected_exception: type[BaseException] | tuple[type[BaseException]],
508
+ callable: Callable[_P, _R],
509
+ *args: _P.args,
510
+ **kwargs: _P.kwargs,
511
+ ) -> BaseException: ...
512
+
513
+ @overload # type: ignore[override]
514
+ def assertRaises(
515
+ self,
516
+ expected_exception: type[BaseException] | tuple[type[BaseException]],
517
+ callable: None = ...,
518
+ ) -> "_AssertRaisesContext": ...
519
+
496
520
  def assertRaises( # type: ignore[override]
497
521
  self,
498
- expected_exception: type[BaseException],
499
- callable: Callable[..., object] | None = None,
500
- *args: object,
501
- **kwargs: object,
522
+ expected_exception: type[BaseException] | tuple[type[BaseException]],
523
+ callable: Callable[_P, _R] | None = None,
524
+ *args: _P.args,
525
+ **kwargs: _P.kwargs,
502
526
  ) -> "_AssertRaisesContext | BaseException":
503
527
  """Fail unless an exception of class expected_exception is thrown
504
528
  by callable when invoked with arguments args and keyword
@@ -654,9 +678,9 @@ class TestCase(unittest.TestCase):
654
678
  def expectFailure(
655
679
  self,
656
680
  reason: str,
657
- predicate: Callable[..., object],
658
- *args: object,
659
- **kwargs: object,
681
+ predicate: Callable[_P, _R],
682
+ *args: _P.args,
683
+ **kwargs: _P.kwargs,
660
684
  ) -> None:
661
685
  """Check that a test fails in a particular way.
662
686
 
@@ -1206,7 +1230,10 @@ class _AssertRaisesContext:
1206
1230
  """
1207
1231
 
1208
1232
  def __init__(
1209
- self, expected: type[BaseException], test_case: TestCase, msg: str | None = None
1233
+ self,
1234
+ expected: type[BaseException] | tuple[type[BaseException]],
1235
+ test_case: TestCase,
1236
+ msg: str | None = None,
1210
1237
  ) -> None:
1211
1238
  """Construct an `_AssertRaisesContext`.
1212
1239
 
@@ -1219,7 +1246,7 @@ class _AssertRaisesContext:
1219
1246
  self.msg = msg
1220
1247
  self.exception: BaseException | None = None
1221
1248
 
1222
- def __enter__(self) -> "_AssertRaisesContext":
1249
+ def __enter__(self) -> "Self":
1223
1250
  return self
1224
1251
 
1225
1252
  def __exit__(
@@ -1322,7 +1349,10 @@ class Nullary:
1322
1349
  """
1323
1350
 
1324
1351
  def __init__(
1325
- self, callable_object: Callable[..., object], *args: object, **kwargs: object
1352
+ self,
1353
+ callable_object: Callable[_P, _R],
1354
+ *args: _P.args,
1355
+ **kwargs: _P.kwargs,
1326
1356
  ) -> None:
1327
1357
  self._callable_object = callable_object
1328
1358
  self._args = args
@@ -58,13 +58,13 @@ def iterate_tests(
58
58
  test_suite_or_case: TestSuiteOrCase,
59
59
  ) -> Generator[unittest.TestCase, None, None]:
60
60
  """Iterate through all of the test cases in 'test_suite_or_case'."""
61
- if isinstance(test_suite_or_case, unittest.TestSuite):
62
- # It's a suite, iterate through it
61
+ if isinstance(test_suite_or_case, Iterable) and not isinstance(
62
+ test_suite_or_case, unittest.TestCase
63
+ ):
63
64
  for test in test_suite_or_case:
64
65
  yield from iterate_tests(test)
65
66
  else:
66
- # It's a test case (could be unittest.TestCase or duck-typed)
67
- yield test_suite_or_case
67
+ yield test_suite_or_case # type: ignore[misc]
68
68
 
69
69
 
70
70
  class ConcurrentTestSuite(unittest.TestSuite):
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes