diff options
Diffstat (limited to 'tests/test_api.py')
-rw-r--r-- | tests/test_api.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_api.py b/tests/test_api.py index 3ea5b3ef..4c038519 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -9,6 +9,7 @@ import sys import textwrap import coverage +from coverage import env from coverage.backward import StringIO from coverage.misc import CoverageException @@ -322,6 +323,26 @@ class ApiTest(CoverageTest): self.assert_exists(".coverage.foo") +class NamespaceModuleTest(CoverageTest): + """Test PEP-420 namespace modules.""" + + def setUp(self): + super(NamespaceModuleTest, self).setUp() + if env.PYVERSION < (3, 3): + self.skip("Python before 3.3 doesn't have namespace packages") + + def test_explicit_namespace_module(self): + self.make_file("namespace/package/module.py", "VAR = 1\n") + self.make_file("main.py", "import namespace\n") + + cov = coverage.Coverage() + self.start_import_stop(cov, "main") + + with self.assertRaisesRegex(CoverageException, r"Module .* has no file"): + cov.analysis(sys.modules['namespace']) + + + class UsingModulesMixin(object): """A mixin for importing modules from test/modules and test/moremodules.""" |