summaryrefslogtreecommitdiff
path: root/tests/test_testing.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2019-11-03 13:59:07 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-11-03 21:27:42 -0500
commit9c04f2d6c4dd4e1bda5fae1e58c9aad846881024 (patch)
treee3120a2caefc141a7b09225aa8e2f40ffb60f939 /tests/test_testing.py
parent25311c6caabed2f13da991dae52352c3c896a3e9 (diff)
downloadpython-coveragepy-git-9c04f2d6c4dd4e1bda5fae1e58c9aad846881024.tar.gz
A better way to import optional modules
Diffstat (limited to 'tests/test_testing.py')
-rw-r--r--tests/test_testing.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 4a4a013c..15e6f84f 100644
--- a/tests/test_testing.py
+++ b/tests/test_testing.py
@@ -15,6 +15,7 @@ import coverage
from coverage.backunittest import TestCase, unittest
from coverage.files import actual_path
from coverage.misc import StopEverything
+import coverage.optional
from tests.coveragetest import CoverageTest, convert_skip_exceptions
from tests.helpers import CheckUniqueFilenames, re_lines, re_line
@@ -308,3 +309,14 @@ def _same_python_executable(e1, e2):
return True
return False # pragma: only failure
+
+
+def test_optional_without():
+ # pylint: disable=reimported
+ from coverage.optional import toml as toml1
+ with coverage.optional.without('toml'):
+ from coverage.optional import toml as toml2
+ from coverage.optional import toml as toml3
+
+ assert toml1 is toml3 is not None
+ assert toml2 is None