diff --git a/NEWS b/NEWS index 20defc5b..028e18a8 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ NEXT Improvements ------------ +* Clear ``force_failure`` in ``_reset()`` so that re-running a test + after an ``expectThat`` failure can succeed if successful conditions are met again. + (OumarCamara, #563) * Make ``extract_result()`` and ``DeferredNotFired`` public APIs in ``testtools.twistedsupport``. These utilities are useful for extracting diff --git a/testtools/testcase.py b/testtools/testcase.py index 3f14011a..334bc2b9 100644 --- a/testtools/testcase.py +++ b/testtools/testcase.py @@ -307,6 +307,9 @@ def _reset(self) -> None: # __details is lazy-initialized so that a constructed-but-not-run # TestCase is safe to use with clone_test_with_new_id. self.__details: DetailsDict | None = None + # force_failure is set by expectThat() on mismatch; must be + # cleared so re-runs of the same test can succeed. + self.force_failure: bool | None = None def __eq__(self, other: object) -> bool: eq = getattr(unittest.TestCase, "__eq__", None)