diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-11-18 19:41:30 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-11-25 14:34:59 -0500 |
commit | b7e0eec3d794ee350f8a4392a0c9cc90fff54fa0 (patch) | |
tree | 0ccbe08a6c6dd24f95789b1b402d1c418e735a39 /tests/test_process.py | |
parent | 41547862ba4a9a948023ade66e41d9f43d9d84c2 (diff) | |
download | python-coveragepy-git-b7e0eec3d794ee350f8a4392a0c9cc90fff54fa0.tar.gz |
PyRunner knows how to run Python files.
Adjust sys.path to better emulate Python, but only if we should.
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index 9f7a16f5..bba58c54 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -861,6 +861,13 @@ class EnvironmentTest(CoverageTest): actual = self.run_command("coverage run run_me.py") self.assert_tryexecfile_output(expected, actual) + def test_coverage_run_far_away_is_like_python(self): + with open(TRY_EXECFILE) as f: + self.make_file("sub/overthere/prog.py", f.read()) + expected = self.run_command("python sub/overthere/prog.py") + actual = self.run_command("coverage run sub/overthere/prog.py") + self.assert_tryexecfile_output(expected, actual) + def test_coverage_run_dashm_is_like_python_dashm(self): # These -m commands assume the coverage tree is on the path. expected = self.run_command("python -m process_test.try_execfile") @@ -904,6 +911,17 @@ class EnvironmentTest(CoverageTest): def test_coverage_run_dashm_superset_of_doubledashsource(self): """Edge case: --source foo -m foo.bar""" + # Ugh: without this config file, we'll get a warning about + # Coverage.py warning: Module process_test was previously imported, + # but not measured (module-not-measured) + # + # This is because process_test/__init__.py is imported while looking + # for process_test.try_execfile. That import happens while setting + # sys.path before start() is called. + self.make_file(".coveragerc", """\ + [run] + disable_warnings = module-not-measured + """) # These -m commands assume the coverage tree is on the path. expected = self.run_command("python -m process_test.try_execfile") actual = self.run_command( |