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 | 6c9ac4a84b53a2d8ca36c3cdc5decd965d24b04d (patch) | |
tree | cae760076642eebd5478e0478c6df97f052ac04d /tests/test_process.py | |
parent | 5b3c821cd1633f1e64bebc2e61060677bceb200e (diff) | |
download | python-coveragepy-git-6c9ac4a84b53a2d8ca36c3cdc5decd965d24b04d.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 35dddd07..70329b59 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 |