summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@canonical.com>2022-04-23 18:31:20 +0100
committerColin Watson <cjwatson@canonical.com>2022-04-23 18:31:20 +0100
commita6f91288bec517762b74e228b8d6c5087cd1252f (patch)
treec1b17b8483e3b706e86e65f1524733e8b90aad9e
parentb1b6442a0c974b9d695e9e9b957ff03f226b5c27 (diff)
downloadfixtures-git-a6f91288bec517762b74e228b8d6c5087cd1252f.tar.gz
Stop using testtools.helpers.try_import
It's only barely more complex to just write out the `try`/`except` directly.
-rw-r--r--fixtures/callmany.py12
-rw-r--r--fixtures/fixture.py9
2 files changed, 11 insertions, 10 deletions
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):