From a6f91288bec517762b74e228b8d6c5087cd1252f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 23 Apr 2022 18:31:20 +0100 Subject: Stop using testtools.helpers.try_import It's only barely more complex to just write out the `try`/`except` directly. --- fixtures/callmany.py | 12 +++++------- fixtures/fixture.py | 9 ++++++--- 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): -- cgit v1.2.1