testtools 2.9.0__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.
Files changed (109) hide show
  1. {testtools-2.9.0 → testtools-2.9.1}/NEWS +8 -2
  2. {testtools-2.9.0 → testtools-2.9.1}/PKG-INFO +1 -1
  3. {testtools-2.9.0 → testtools-2.9.1}/tests/test_testresult.py +43 -3
  4. {testtools-2.9.0 → testtools-2.9.1}/testtools/_types.py +1 -1
  5. {testtools-2.9.0 → testtools-2.9.1}/testtools/_version.py +2 -2
  6. {testtools-2.9.0 → testtools-2.9.1}/testtools/testresult/real.py +10 -8
  7. {testtools-2.9.0 → testtools-2.9.1}/.git-blame-ignore-revs +0 -0
  8. {testtools-2.9.0 → testtools-2.9.1}/.github/dependabot.yaml +0 -0
  9. {testtools-2.9.0 → testtools-2.9.1}/.github/workflows/publish.yml +0 -0
  10. {testtools-2.9.0 → testtools-2.9.1}/.github/workflows/test.yml +0 -0
  11. {testtools-2.9.0 → testtools-2.9.1}/.gitignore +0 -0
  12. {testtools-2.9.0 → testtools-2.9.1}/.gitreview +0 -0
  13. {testtools-2.9.0 → testtools-2.9.1}/.testr.conf +0 -0
  14. {testtools-2.9.0 → testtools-2.9.1}/LICENSE +0 -0
  15. {testtools-2.9.0 → testtools-2.9.1}/MANIFEST.in +0 -0
  16. {testtools-2.9.0 → testtools-2.9.1}/Makefile +0 -0
  17. {testtools-2.9.0 → testtools-2.9.1}/README.rst +0 -0
  18. {testtools-2.9.0 → testtools-2.9.1}/disperse.conf +0 -0
  19. {testtools-2.9.0 → testtools-2.9.1}/doc/Makefile +0 -0
  20. {testtools-2.9.0 → testtools-2.9.1}/doc/_static/placeholder.txt +0 -0
  21. {testtools-2.9.0 → testtools-2.9.1}/doc/_templates/placeholder.txt +0 -0
  22. {testtools-2.9.0 → testtools-2.9.1}/doc/api.rst +0 -0
  23. {testtools-2.9.0 → testtools-2.9.1}/doc/conf.py +0 -0
  24. {testtools-2.9.0 → testtools-2.9.1}/doc/for-framework-folk.rst +0 -0
  25. {testtools-2.9.0 → testtools-2.9.1}/doc/for-test-authors.rst +0 -0
  26. {testtools-2.9.0 → testtools-2.9.1}/doc/hacking.rst +0 -0
  27. {testtools-2.9.0 → testtools-2.9.1}/doc/index.rst +0 -0
  28. {testtools-2.9.0 → testtools-2.9.1}/doc/make.bat +0 -0
  29. {testtools-2.9.0 → testtools-2.9.1}/doc/news.rst +0 -0
  30. {testtools-2.9.0 → testtools-2.9.1}/doc/overview.rst +0 -0
  31. {testtools-2.9.0 → testtools-2.9.1}/doc/twisted-support.rst +0 -0
  32. {testtools-2.9.0 → testtools-2.9.1}/pyproject.toml +0 -0
  33. {testtools-2.9.0 → testtools-2.9.1}/readthedocs-requirements.txt +0 -0
  34. {testtools-2.9.0 → testtools-2.9.1}/requirements.txt +0 -0
  35. {testtools-2.9.0 → testtools-2.9.1}/scripts/README +0 -0
  36. {testtools-2.9.0 → testtools-2.9.1}/scripts/all-pythons +0 -0
  37. {testtools-2.9.0 → testtools-2.9.1}/scripts/update-rtfd +0 -0
  38. {testtools-2.9.0 → testtools-2.9.1}/tests/__init__.py +0 -0
  39. {testtools-2.9.0 → testtools-2.9.1}/tests/helpers.py +0 -0
  40. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/__init__.py +0 -0
  41. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_basic.py +0 -0
  42. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_const.py +0 -0
  43. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_datastructures.py +0 -0
  44. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_dict.py +0 -0
  45. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_doctest.py +0 -0
  46. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_exception.py +0 -0
  47. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_filesystem.py +0 -0
  48. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_higherorder.py +0 -0
  49. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_impl.py +0 -0
  50. {testtools-2.9.0 → testtools-2.9.1}/tests/matchers/test_warnings.py +0 -0
  51. {testtools-2.9.0 → testtools-2.9.1}/tests/samplecases.py +0 -0
  52. {testtools-2.9.0 → testtools-2.9.1}/tests/test_assert_that.py +0 -0
  53. {testtools-2.9.0 → testtools-2.9.1}/tests/test_compat.py +0 -0
  54. {testtools-2.9.0 → testtools-2.9.1}/tests/test_content.py +0 -0
  55. {testtools-2.9.0 → testtools-2.9.1}/tests/test_content_type.py +0 -0
  56. {testtools-2.9.0 → testtools-2.9.1}/tests/test_fixturesupport.py +0 -0
  57. {testtools-2.9.0 → testtools-2.9.1}/tests/test_helpers.py +0 -0
  58. {testtools-2.9.0 → testtools-2.9.1}/tests/test_monkey.py +0 -0
  59. {testtools-2.9.0 → testtools-2.9.1}/tests/test_run.py +0 -0
  60. {testtools-2.9.0 → testtools-2.9.1}/tests/test_runtest.py +0 -0
  61. {testtools-2.9.0 → testtools-2.9.1}/tests/test_tags.py +0 -0
  62. {testtools-2.9.0 → testtools-2.9.1}/tests/test_testcase.py +0 -0
  63. {testtools-2.9.0 → testtools-2.9.1}/tests/test_testsuite.py +0 -0
  64. {testtools-2.9.0 → testtools-2.9.1}/tests/test_with_with.py +0 -0
  65. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/__init__.py +0 -0
  66. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/_helpers.py +0 -0
  67. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/test_deferred.py +0 -0
  68. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/test_matchers.py +0 -0
  69. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/test_runtest.py +0 -0
  70. {testtools-2.9.0 → testtools-2.9.1}/tests/twistedsupport/test_spinner.py +0 -0
  71. {testtools-2.9.0 → testtools-2.9.1}/testtools/__init__.py +0 -0
  72. {testtools-2.9.0 → testtools-2.9.1}/testtools/_version.pyi +0 -0
  73. {testtools-2.9.0 → testtools-2.9.1}/testtools/assertions.py +0 -0
  74. {testtools-2.9.0 → testtools-2.9.1}/testtools/compat.py +0 -0
  75. {testtools-2.9.0 → testtools-2.9.1}/testtools/content.py +0 -0
  76. {testtools-2.9.0 → testtools-2.9.1}/testtools/content_type.py +0 -0
  77. {testtools-2.9.0 → testtools-2.9.1}/testtools/helpers.py +0 -0
  78. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/__init__.py +0 -0
  79. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_basic.py +0 -0
  80. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_const.py +0 -0
  81. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_datastructures.py +0 -0
  82. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_dict.py +0 -0
  83. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_doctest.py +0 -0
  84. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_exception.py +0 -0
  85. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_filesystem.py +0 -0
  86. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_higherorder.py +0 -0
  87. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_impl.py +0 -0
  88. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/_warnings.py +0 -0
  89. {testtools-2.9.0 → testtools-2.9.1}/testtools/matchers/test.py +0 -0
  90. {testtools-2.9.0 → testtools-2.9.1}/testtools/monkey.py +0 -0
  91. {testtools-2.9.0 → testtools-2.9.1}/testtools/py.typed +0 -0
  92. {testtools-2.9.0 → testtools-2.9.1}/testtools/run.py +0 -0
  93. {testtools-2.9.0 → testtools-2.9.1}/testtools/runtest.py +0 -0
  94. {testtools-2.9.0 → testtools-2.9.1}/testtools/tags.py +0 -0
  95. {testtools-2.9.0 → testtools-2.9.1}/testtools/testcase.py +0 -0
  96. {testtools-2.9.0 → testtools-2.9.1}/testtools/testresult/__init__.py +0 -0
  97. {testtools-2.9.0 → testtools-2.9.1}/testtools/testresult/doubles.py +0 -0
  98. {testtools-2.9.0 → testtools-2.9.1}/testtools/tests/__init__.py +0 -0
  99. {testtools-2.9.0 → testtools-2.9.1}/testtools/tests/helpers.py +0 -0
  100. {testtools-2.9.0 → testtools-2.9.1}/testtools/tests/matchers/__init__.py +0 -0
  101. {testtools-2.9.0 → testtools-2.9.1}/testtools/tests/matchers/helpers.py +0 -0
  102. {testtools-2.9.0 → testtools-2.9.1}/testtools/testsuite.py +0 -0
  103. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/__init__.py +0 -0
  104. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/_deferred.py +0 -0
  105. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/_deferreddebug.py +0 -0
  106. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/_matchers.py +0 -0
  107. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/_runtest.py +0 -0
  108. {testtools-2.9.0 → testtools-2.9.1}/testtools/twistedsupport/_spinner.py +0 -0
  109. {testtools-2.9.0 → testtools-2.9.1}/tox.ini +0 -0
@@ -3,8 +3,14 @@ testtools NEWS
3
3
 
4
4
  Changes and improvements to testtools_, grouped by release.
5
5
 
6
- NEXT
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)
8
14
 
9
15
  2.9.0
10
16
  ~~~~~
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: testtools
3
- Version: 2.9.0
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>
@@ -16,7 +16,15 @@ import threading
16
16
  from itertools import chain, combinations
17
17
  from queue import Queue
18
18
  from typing import Any
19
- from unittest import TestSuite
19
+ from unittest import (
20
+ TestCase as StdlibTestCase,
21
+ )
22
+ from unittest import (
23
+ TestResult as StdlibTestResult,
24
+ )
25
+ from unittest import (
26
+ TestSuite,
27
+ )
20
28
 
21
29
  from testtools import (
22
30
  CopyStreamResult,
@@ -2962,9 +2970,11 @@ class TestExtendedToOriginalResultDecoratorBase(TestCase):
2962
2970
  event_outcome, event_test, event_err = self.result._events[0]
2963
2971
  self.assertEqual(expected, event_outcome)
2964
2972
  self.assertEqual(self, event_test)
2965
- # Compare exc type and value; traceback objects differ between calls
2973
+ # Compare exc type and value; traceback is always None because the
2974
+ # exception is synthesised, not raised from user code — attaching a
2975
+ # live traceback would leak testtools internals into error reports.
2966
2976
  self.assertEqual(expected_err[:2], event_err[:2])
2967
- self.assertIsNotNone(event_err[2])
2977
+ self.assertIsNone(event_err[2])
2968
2978
 
2969
2979
  def check_outcome_details_to_nothing(self, outcome, expected=None):
2970
2980
  """Call an outcome with a details dict to be swallowed."""
@@ -3139,6 +3149,36 @@ class TestExtendedToOriginalAddFailure(TestExtendedToOriginalAddError):
3139
3149
  outcome = "addFailure"
3140
3150
 
3141
3151
 
3152
+ class TestExtendedToOriginalDetailsStdlibReport(TestCase):
3153
+ """Regression test: details converted to exc_info for a stdlib TestResult
3154
+ must not cause testtools' own frames to appear in the error report.
3155
+
3156
+ Before the fix for the 2.9.0 regression, ``_details_to_exc_info`` returned
3157
+ a live traceback pointing into ``testresult/real.py`` itself, which
3158
+ ``unittest.TestResult._exc_info_to_string`` then formatted into the
3159
+ user-visible string.
3160
+ """
3161
+
3162
+ def _report_for(self, outcome, events_attr):
3163
+ client = StdlibTestResult()
3164
+ decorator = ExtendedToOriginalDecorator(client)
3165
+ details = {"traceback": text_content("foo.c:53:ERROR invalid state\n")}
3166
+ getattr(decorator, outcome)(StdlibTestCase("run"), details=details)
3167
+ events = getattr(client, events_attr)
3168
+ self.assertEqual(1, len(events))
3169
+ return events[0][1]
3170
+
3171
+ def test_add_error(self):
3172
+ report = self._report_for("addError", "errors")
3173
+ self.assertNotIn("testresult/real.py", report)
3174
+ self.assertNotIn("Traceback (most recent call last)", report)
3175
+
3176
+ def test_add_failure(self):
3177
+ report = self._report_for("addFailure", "failures")
3178
+ self.assertNotIn("testresult/real.py", report)
3179
+ self.assertNotIn("Traceback (most recent call last)", report)
3180
+
3181
+
3142
3182
  class TestExtendedToOriginalAddExpectedFailure(TestExtendedToOriginalAddError):
3143
3183
  outcome = "addExpectedFailure"
3144
3184
 
@@ -4,5 +4,5 @@ from types import TracebackType
4
4
  from typing import TypeAlias
5
5
 
6
6
  # Type for exc_info tuples from sys.exc_info()
7
- ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType]
7
+ ExcInfo: TypeAlias = tuple[type[BaseException], BaseException, TracebackType | None]
8
8
  OptExcInfo: TypeAlias = ExcInfo | tuple[None, None, None]
@@ -1,3 +1,3 @@
1
1
  # This file is automatically generated by hatch.
2
- version = '2.9.0'
3
- __version__ = (2, 9, 0)
2
+ version = '2.9.1'
3
+ __version__ = (2, 9, 1)
@@ -39,7 +39,6 @@ from typing import (
39
39
  TypeAlias,
40
40
  TypedDict,
41
41
  TypeVar,
42
- cast,
43
42
  )
44
43
 
45
44
  if TYPE_CHECKING:
@@ -2113,12 +2112,15 @@ class ExtendedToOriginalDecorator:
2113
2112
  )
2114
2113
 
2115
2114
  def _details_to_exc_info(self, details: DetailsDict) -> ExcInfo:
2116
- """Convert a details dict to an exc_info tuple."""
2117
- try:
2118
- raise _StringException(_details_to_str(details, special="traceback"))
2119
- except _StringException:
2120
- # we know this won't be null
2121
- return cast(ExcInfo, sys.exc_info())
2115
+ """Convert a details dict to an exc_info tuple.
2116
+
2117
+ The returned tuple has ``tb=None`` on purpose: the exception is
2118
+ synthesised here, not raised by user code, so attaching a live
2119
+ traceback would leak testtools' own internals into the user-visible
2120
+ error report emitted by e.g. ``unittest.TestResult._exc_info_to_string``.
2121
+ """
2122
+ exc = _StringException(_details_to_str(details, special="traceback"))
2123
+ return (_StringException, exc, None)
2122
2124
 
2123
2125
  @property
2124
2126
  def current_tags(self) -> set[str]:
@@ -2755,7 +2757,7 @@ class TestResultDecorator:
2755
2757
  subtest: unittest.TestCase,
2756
2758
  err: OptExcInfo | None,
2757
2759
  ) -> None:
2758
- self.decorated.addSubTest(test, subtest, err)
2760
+ self.decorated.addSubTest(test, subtest, err) # type: ignore[arg-type]
2759
2761
 
2760
2762
  def addDuration(self, test: unittest.TestCase, duration: float) -> None:
2761
2763
  self.decorated.addDuration(test, duration)
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
File without changes
File without changes