summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@canonical.com>2022-04-25 02:05:24 +0100
committerGitHub <noreply@github.com>2022-04-25 02:05:24 +0100
commitfbd4e51ed7695b32d753313970e1632b3f41ef60 (patch)
tree7f1dcc0f739c0413602b007937be3cf2a98eedde
parentb1b6442a0c974b9d695e9e9b957ff03f226b5c27 (diff)
parent97c53a365961e69266cde0b11b9b39cf0bb444ab (diff)
downloadfixtures-git-fbd4e51ed7695b32d753313970e1632b3f41ef60.tar.gz
Merge pull request #62 from cjwatson/move-testtools-to-extra
Move testtools requirement to a "streams" extra
-rw-r--r--NEWS1
-rw-r--r--README.rst6
-rw-r--r--fixtures/_fixtures/streams.py9
-rw-r--r--fixtures/callmany.py12
-rw-r--r--fixtures/fixture.py9
-rw-r--r--setup.cfg3
6 files changed, 27 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index 1439d53..79102bf 100644
--- a/NEWS
+++ b/NEWS
@@ -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
~~~~~
diff --git a/README.rst b/README.rst
index b60d993..4b12e8e 100644
--- a/README.rst
+++ b/README.rst
@@ -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):
diff --git a/setup.cfg b/setup.cfg
index 0016fa7..21589e9 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -31,7 +31,10 @@ packages =
fixtures
[extras]
+streams =
+ testtools
test =
mock
+ testtools
docs =
docutils