diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2020-01-02 22:01:17 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2020-01-03 07:31:06 -0500 |
commit | 7541b4f642534b382244f1174991df00b2efb9f3 (patch) | |
tree | 1171fb629f84e9232aafbd5e6bc3e4f9def2ea56 /tests/test_process.py | |
parent | 016af5f6352d69206ac8f7537c2b18828767bcae (diff) | |
download | python-coveragepy-git-7541b4f642534b382244f1174991df00b2efb9f3.tar.gz |
A test for #909
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index 1414de6c..9aade773 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -1004,6 +1004,34 @@ class EnvironmentTest(CoverageTest): out = self.run_command("python -m run_coverage run how_is_it.py") self.assertIn("hello-xyzzy", out) + def test_bug_909(self): + # https://github.com/nedbat/coveragepy/issues/909 + # The __init__ files were being imported before measurement started, + # so the line in __init__.py was being marked as missed, and there were + # warnings about measured files being imported before start. + self.make_file("proj/__init__.py", "print('Init')") + self.make_file("proj/thecode.py", "print('The code')") + self.make_file("proj/tests/__init__.py", "") + self.make_file("proj/tests/test_it.py", "import proj.thecode") + + expected = "Init\nThe code\n" + actual = self.run_command("coverage run --source=proj -m proj.tests.test_it") + assert expected == actual + + report = self.run_command("coverage report -m") + + # Name Stmts Miss Cover Missing + # ------------------------------------------------------ + # proj/__init__.py 1 0 100% + # proj/tests/__init__.py 0 0 100% + # proj/tests/test_it.py 1 0 100% + # proj/thecode.py 1 0 100% + # ------------------------------------------------------ + # TOTAL 3 0 100% + + squeezed = self.squeezed_lines(report) + assert squeezed[2].replace("\\", "/") == "proj/__init__.py 1 0 100%" + class ExcepthookTest(CoverageTest): """Tests of sys.excepthook support.""" |