diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-16 08:16:38 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-10-16 08:20:38 -0400 |
commit | 68b0094de2a0a92477dfe44ead0cb46f4de26d4b (patch) | |
tree | b89b93b3f7b23ddea635a2609239732029f5a464 /tests/test_process.py | |
parent | 702c927fed2b2120ed2e4aa66668170d4120ca30 (diff) | |
download | python-coveragepy-git-nedbat/run_envvar_553.tar.gz |
feat: `coverage run` now sets the COVERAGE_RUN environment variablenedbat/run_envvar_553
Diffstat (limited to 'tests/test_process.py')
-rw-r--r-- | tests/test_process.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/test_process.py b/tests/test_process.py index c9a2f8ee..7508430c 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -39,7 +39,7 @@ class ProcessTest(CoverageTest): self.run_command("coverage run mycode.py") self.assert_exists(".coverage") - def test_environment(self): + def test_tests_dir_is_importable(self): # Checks that we can import modules from the tests directory at all! self.make_file("mycode.py", """\ import covmod1 @@ -53,6 +53,24 @@ class ProcessTest(CoverageTest): self.assert_exists(".coverage") assert out == 'done\n' + def test_coverage_run_envvar_isnt_in_python(self): + # Test that we aren't smearing COVERAGE_RUN all over the place. + self.make_file("envornot.py", """\ + import os + print(os.environ.get("COVERAGE_RUN", "nope")) + """) + out = self.run_command("python envornot.py") + assert out == "nope\n" + + def test_coverage_run_envvar_is_in_coveragerun(self): + # Test that we are setting COVERAGE_RUN when we run. + self.make_file("envornot.py", """\ + import os + print(os.environ.get("COVERAGE_RUN", "nope")) + """) + out = self.run_command("coverage run envornot.py") + assert out == "true\n" + def make_b_or_c_py(self): """Create b_or_c.py, used in a few of these tests.""" # "b_or_c.py b" will run 6 lines. |