diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-03 15:21:15 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2023-01-03 15:29:00 -0500 |
commit | 4f3ccf213d813bb57775b2643b8bae5e08cbbbd0 (patch) | |
tree | fb113cb24362ee3fd67825867874ce3aa713b55e /tests/test_misc.py | |
parent | 98301ed240a141592573c2ed239e006d42a26161 (diff) | |
download | python-coveragepy-git-4f3ccf213d813bb57775b2643b8bae5e08cbbbd0.tar.gz |
refactor: a better way to have maybe-importable third-party modules
Diffstat (limited to 'tests/test_misc.py')
-rw-r--r-- | tests/test_misc.py | 7 |
1 files changed, 4 insertions, 3 deletions
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 |