Skip to content

Commit a30311c

Browse files
committed
Fix regressions
1 parent 9b02562 commit a30311c

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

testtools/_version.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Type stub for auto-generated _version module
2-
__version__: tuple[int | str, ...]
2+
from typing import Union
3+
4+
__version__: tuple[Union[int, str], ...] # noqa: UP007
35
version: str

testtools/testresult/real.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import sys
2929
import unittest
3030
from operator import methodcaller
31-
from typing import ClassVar
31+
from typing import ClassVar, Union
3232

3333
from testtools.compat import _b
3434
from testtools.content import (
@@ -1668,7 +1668,7 @@ def __init__(self, decorated):
16681668
# Deal with mismatched base class constructors.
16691669
TestControl.__init__(self)
16701670
self._started = False
1671-
self._tags: TagContext | None = None
1671+
self._tags: Union[TagContext, None] = None
16721672

16731673
def _get_failfast(self):
16741674
return len(self.targets) == 2

testtools/tests/helpers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ def addError(self, test, err=None, details=None):
5454
super().addError(test, err, details)
5555

5656
def addSkip(self, test, reason=None, details=None):
57+
# Extract reason from details if not provided directly
58+
if reason is None and details and "reason" in details:
59+
reason = details["reason"].as_text()
5760
self._events.append(("addSkip", test, reason))
5861
super().addSkip(test, reason, details)
5962

testtools/tests/matchers/test_higherorder.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ class TestAnyMatch(TestCase, TestMatchersInterface):
8181
]
8282

8383

84-
class TestAfterPreprocessing(TestCase, TestMatchersInterface):
85-
@staticmethod
86-
def parity(x):
87-
return x % 2
84+
def parity(x):
85+
return x % 2
86+
8887

88+
class TestAfterPreprocessing(TestCase, TestMatchersInterface):
8989
matches_matcher: ClassVar = AfterPreprocessing(parity, Equals(1))
9090
matches_matches: ClassVar = [3, 5]
9191
matches_mismatches: ClassVar = [2]

testtools/tests/test_testsuite.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import doctest
66
import unittest
77
from pprint import pformat
8+
from typing import Union
89

910
from testtools import (
1011
ConcurrentStreamTestSuite,
@@ -353,7 +354,7 @@ def setUp(self):
353354
self.skipTest("Need fixtures")
354355

355356
def test_fixture_suite(self):
356-
log: list[int | str] = []
357+
log: list[Union[int, str]] = []
357358

358359
class Sample(TestCase):
359360
def test_one(self):
@@ -370,7 +371,7 @@ def test_two(self):
370371
self.assertEqual(["setUp", 1, 2, "tearDown"], log)
371372

372373
def test_fixture_suite_sort(self):
373-
log: list[int | str] = []
374+
log: list[Union[int, str]] = []
374375

375376
class Sample(TestCase):
376377
def test_one(self):

0 commit comments

Comments
 (0)