diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-20 08:26:35 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-02-20 08:26:35 -0500 |
commit | 12955ec533a5186702593130c5b194a3a69d1807 (patch) | |
tree | 2abd4b2f47bf4fd292d7a9f6ee1438a8dbd0e01f /tests/test_process.py | |
parent | 7cc26bfa090f4cf9b6a3799d420539f757ee60d8 (diff) | |
download | python-coveragepy-12955ec533a5186702593130c5b194a3a69d1807.tar.gz |
A new warning for files already imported before coverage starts
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index 35dddd0..70329b5 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -585,6 +585,30 @@ class ProcessTest(CoverageTest): self.assertIn("Trace function changed", out) + def test_warn_preimported(self): + self.make_file("hello.py", """\ + import goodbye + import coverage + cov = coverage.Coverage(include=["good*"]) + cov.start() + print(goodbye.f()) + cov.stop() + """) + self.make_file("goodbye.py", """\ + def f(): + return "Goodbye!" + """) + goodbye_path = os.path.abspath("goodbye.py") + + out = self.run_command("python hello.py") + self.assertIn("Goodbye!", out) + + msg = ( + "Coverage.py warning: " + "Already imported a file that will be measured: {0} " + "(already-imported)").format(goodbye_path) + self.assertIn(msg, out) + def test_note(self): if env.PYPY and env.PY3 and env.PYPYVERSION[:3] == (5, 10, 0): # https://bitbucket.org/pypy/pypy/issues/2729/pypy3-510-incorrectly-decodes-astral-plane |