From 4f3ccf213d813bb57775b2643b8bae5e08cbbbd0 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 3 Jan 2023 15:21:15 -0500 Subject: refactor: a better way to have maybe-importable third-party modules --- tests/test_misc.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'tests/test_misc.py') diff --git a/tests/test_misc.py b/tests/test_misc.py index 4fd3f7c7..745522b0 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -118,7 +118,8 @@ class ImportThirdPartyTest(CoverageTest): # Make sure we don't have pytest in sys.modules before we start. del sys.modules["pytest"] # Import pytest - mod = import_third_party("pytest") + mod, has = import_third_party("pytest") + assert has # Yes, it's really pytest: assert mod.__name__ == "pytest" print(dir(mod)) @@ -127,8 +128,8 @@ class ImportThirdPartyTest(CoverageTest): assert "pytest" not in sys.modules def test_failure(self): - mod = import_third_party("xyzzy") - assert mod is None + _, has = import_third_party("xyzzy") + assert not has assert "xyzzy" not in sys.modules -- cgit v1.2.1