From 0d9f1c7e0e414603d212f0aaffaa193748a15e3f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 23 Apr 2022 18:53:53 +0100 Subject: Use CompoundFixture from fixtures>=2.0 rather than rolling our own `fixtures` 2.0 was released in 2016. --- NEWS | 3 +++ requirements.txt | 2 +- testtools/twistedsupport/_runtest.py | 18 ++---------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 91068c2..e159343 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ Improvements * Distutils integration is deprecated and will be removed in the next major version. +* Use ``CompoundFixture`` from ``fixtures>=2.0`` rather than rolling our + own. + 2.5.0 ~~~~~ diff --git a/requirements.txt b/requirements.txt index 4a7c1d4..3cfa9bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ pbr>=0.11 # TODO(stephenfin): Remove this once fixtures no longer depends on extras # or explicitly specifies the dependency extras>=1.0.0 -fixtures>=1.3.0 +fixtures>=2.0 diff --git a/testtools/twistedsupport/_runtest.py b/testtools/twistedsupport/_runtest.py index c8860e9..d4f7775 100644 --- a/testtools/twistedsupport/_runtest.py +++ b/testtools/twistedsupport/_runtest.py @@ -30,7 +30,7 @@ import io import warnings import sys -from fixtures import Fixture +from fixtures import CompoundFixture, Fixture from testtools.content import Content, text_content from testtools.content_type import UTF8_TEXT @@ -194,20 +194,6 @@ def run_with_log_observers(observers, function, *args, **kwargs): _log_observer = _LogObserver() -# XXX: Should really be in python-fixtures. -# See https://github.com/testing-cabal/fixtures/pull/22. -class _CompoundFixture(Fixture): - """A fixture that combines many fixtures.""" - - def __init__(self, fixtures): - super().__init__() - self._fixtures = fixtures - - def _setUp(self): - for fixture in self._fixtures: - self.useFixture(fixture) - - def flush_logged_errors(*error_types): """Flush errors of the given types from the global Twisted log. @@ -411,7 +397,7 @@ class AsynchronousDeferredRunTest(_DeferredRunTest): fixtures.append(_NoTwistedLogObservers()) if self._store_twisted_logs: fixtures.append(CaptureTwistedLogs()) - return _CompoundFixture(fixtures) + return CompoundFixture(fixtures) def _run_core(self): # XXX: Blatting over the namespace of the test case isn't a nice thing -- cgit v1.2.1