|
| 1 | +Description: Fix compatibility with newer testtools |
| 2 | + These no longer provide testtools.tests |
| 3 | +Author: Jelmer Vernooij <jelmer@jelmer.uk> |
| 4 | +Origin: upstream, https://github.com/testing-cabal/testscenarios/commit/75b76e7d07bc6d415384e668aefb6b887a3aa13d |
| 5 | +Bug-Debian: https://bugs.debian.org/1124202 |
| 6 | +Date: Mon, 22 Dec 2025 20:10:49 +0000 |
| 7 | + |
| 8 | +Index: python-testscenarios/testscenarios/tests/test_testcase.py |
| 9 | +=================================================================== |
| 10 | +--- python-testscenarios.orig/testscenarios/tests/test_testcase.py |
| 11 | ++++ python-testscenarios/testscenarios/tests/test_testcase.py |
| 12 | +@@ -18,10 +18,68 @@ import unittest |
| 13 | + |
| 14 | + import testtools |
| 15 | + from testtools.matchers import EndsWith |
| 16 | +-from testtools.tests.helpers import LoggingResult |
| 17 | + |
| 18 | + import testscenarios |
| 19 | + |
| 20 | ++class LoggingResult(testtools.TestResult): |
| 21 | ++ """TestResult that logs its event to a list.""" |
| 22 | ++ |
| 23 | ++ def __init__(self, log): |
| 24 | ++ self._events = log |
| 25 | ++ super().__init__() |
| 26 | ++ |
| 27 | ++ def startTest(self, test): |
| 28 | ++ self._events.append(("startTest", test)) |
| 29 | ++ super().startTest(test) |
| 30 | ++ |
| 31 | ++ def stop(self): |
| 32 | ++ self._events.append("stop") |
| 33 | ++ super().stop() |
| 34 | ++ |
| 35 | ++ def stopTest(self, test): |
| 36 | ++ self._events.append(("stopTest", test)) |
| 37 | ++ super().stopTest(test) |
| 38 | ++ |
| 39 | ++ def addFailure(self, test, err=None, details=None): |
| 40 | ++ self._events.append(("addFailure", test, err)) |
| 41 | ++ super().addFailure(test, err, details) |
| 42 | ++ |
| 43 | ++ def addError(self, test, err=None, details=None): |
| 44 | ++ self._events.append(("addError", test, err)) |
| 45 | ++ super().addError(test, err, details) |
| 46 | ++ |
| 47 | ++ def addSkip(self, test, reason=None, details=None): |
| 48 | ++ # Extract reason from details if not provided directly |
| 49 | ++ if reason is None and details and "reason" in details: |
| 50 | ++ reason = details["reason"].as_text() |
| 51 | ++ self._events.append(("addSkip", test, reason)) |
| 52 | ++ super().addSkip(test, reason, details) |
| 53 | ++ |
| 54 | ++ def addSuccess(self, test, details=None): |
| 55 | ++ self._events.append(("addSuccess", test)) |
| 56 | ++ super().addSuccess(test, details) |
| 57 | ++ |
| 58 | ++ def startTestRun(self): |
| 59 | ++ self._events.append("startTestRun") |
| 60 | ++ super().startTestRun() |
| 61 | ++ |
| 62 | ++ def stopTestRun(self): |
| 63 | ++ self._events.append("stopTestRun") |
| 64 | ++ super().stopTestRun() |
| 65 | ++ |
| 66 | ++ def done(self): |
| 67 | ++ self._events.append("done") |
| 68 | ++ super().done() |
| 69 | ++ |
| 70 | ++ def tags(self, new_tags, gone_tags): |
| 71 | ++ self._events.append(("tags", new_tags, gone_tags)) |
| 72 | ++ super().tags(new_tags, gone_tags) |
| 73 | ++ |
| 74 | ++ def time(self, a_datetime): |
| 75 | ++ self._events.append(("time", a_datetime)) |
| 76 | ++ super().time(a_datetime) |
| 77 | ++ |
| 78 | ++ |
| 79 | + class TestTestWithScenarios(testtools.TestCase): |
| 80 | + |
| 81 | + scenarios = testscenarios.scenarios.per_module_scenarios( |
| 82 | +Index: python-testscenarios/testscenarios/tests/test_scenarios.py |
| 83 | +=================================================================== |
| 84 | +--- python-testscenarios.orig/testscenarios/tests/test_scenarios.py |
| 85 | ++++ python-testscenarios/testscenarios/tests/test_scenarios.py |
| 86 | +@@ -20,7 +20,7 @@ import unittest |
| 87 | + import testtools |
| 88 | + from testtools.matchers import EndsWith |
| 89 | + |
| 90 | +-from testtools.tests.helpers import LoggingResult |
| 91 | ++from testscenarios.tests.test_testcase import LoggingResult |
| 92 | + |
| 93 | + import testscenarios |
| 94 | + from testscenarios.scenarios import ( |
0 commit comments