diff options
author | Colin Watson <cjwatson@canonical.com> | 2022-04-25 02:05:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 02:05:24 +0100 |
commit | fbd4e51ed7695b32d753313970e1632b3f41ef60 (patch) | |
tree | 7f1dcc0f739c0413602b007937be3cf2a98eedde | |
parent | b1b6442a0c974b9d695e9e9b957ff03f226b5c27 (diff) | |
parent | 97c53a365961e69266cde0b11b9b39cf0bb444ab (diff) | |
download | fixtures-git-fbd4e51ed7695b32d753313970e1632b3f41ef60.tar.gz |
Merge pull request #62 from cjwatson/move-testtools-to-extra
Move testtools requirement to a "streams" extra
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | README.rst | 6 | ||||
-rw-r--r-- | fixtures/_fixtures/streams.py | 9 | ||||
-rw-r--r-- | fixtures/callmany.py | 12 | ||||
-rw-r--r-- | fixtures/fixture.py | 9 | ||||
-rw-r--r-- | setup.cfg | 3 |
6 files changed, 27 insertions, 13 deletions
@@ -8,6 +8,7 @@ NEXT * Dropped support for Python 2.7, Python 3.4 and Python 3.5 (EOL). * Added support for Python 3.7-3.10. * Support all ``subprocess.Popen`` arguments up to Python 3.10. +* Move ``testtools`` requirement to a new ``fixtures[streams]`` extra. 3.0.0 ~~~~~ @@ -31,6 +31,8 @@ Dependencies * pbr Used for version and release management of fixtures. +The ``fixtures[streams]`` extra adds: + * testtools <https://launchpad.net/testtools> 0.9.22 or newer. testtools provides helpful glue functions for the details API used to report information about a fixture (whether its used in a testing or production @@ -336,6 +338,8 @@ in test failure descriptions. Very useful in combination with MonkeyPatch. ... pass >>> fixture.cleanUp() +This requires the ``fixtures[streams]`` extra. + EnvironmentVariable +++++++++++++++++++ @@ -450,6 +454,8 @@ in test failure descriptions. Very useful in combination with MonkeyPatch. ... pass >>> fixture.cleanUp() +This requires the ``fixtures[streams]`` extra. + TempDir +++++++ diff --git a/fixtures/_fixtures/streams.py b/fixtures/_fixtures/streams.py index 7686376..c0fb60a 100644 --- a/fixtures/_fixtures/streams.py +++ b/fixtures/_fixtures/streams.py @@ -22,7 +22,6 @@ __all__ = [ import io from fixtures import Fixture -import testtools class Stream(Fixture): @@ -42,10 +41,14 @@ class Stream(Fixture): self._stream_factory = stream_factory def _setUp(self): + # Available with the fixtures[streams] extra. + from testtools.content import content_from_stream + write_stream, read_stream = self._stream_factory() self.stream = write_stream - self.addDetail(self._detail_name, - testtools.content.content_from_stream(read_stream, seek_offset=0)) + self.addDetail( + self._detail_name, + content_from_stream(read_stream, seek_offset=0)) def _byte_stream_factory(): diff --git a/fixtures/callmany.py b/fixtures/callmany.py index 39b23ef..b1785b4 100644 --- a/fixtures/callmany.py +++ b/fixtures/callmany.py @@ -19,14 +19,12 @@ __all__ = [ import sys -from testtools.helpers import try_import - -class MultipleExceptions(Exception): - """Report multiple exc_info tuples in self.args.""" - -MultipleExceptions = try_import( - "testtools.MultipleExceptions", MultipleExceptions) +try: + from testtools import MultipleExceptions +except ImportError: + class MultipleExceptions(Exception): + """Report multiple exc_info tuples in self.args.""" class CallMany(object): diff --git a/fixtures/fixture.py b/fixtures/fixture.py index cdfdc76..e0ad4c7 100644 --- a/fixtures/fixture.py +++ b/fixtures/fixture.py @@ -25,15 +25,18 @@ __all__ = [ import itertools import sys -from testtools.helpers import try_import - from fixtures.callmany import ( CallMany, # Deprecated, imported for compatibility. MultipleExceptions, ) -gather_details = try_import("testtools.testcase.gather_details") + +try: + from testtools.testcase import gather_details +except ImportError: + gather_details = None + # This would be better in testtools (or a common library) def combine_details(source_details, target_details): @@ -31,7 +31,10 @@ packages = fixtures [extras] +streams = + testtools test = mock + testtools docs = docutils |