diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2018-11-18 10:49:58 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2018-11-18 10:49:58 -0500 |
commit | 701f4ed56639325dcb9fa0aecf06df303ee6a761 (patch) | |
tree | 575b1d500eb4b0f22c64163a96f1a9dafb0d179a /tests | |
parent | 55ab51bdae6e578f544926da777246ca0ab369e3 (diff) | |
download | python-coveragepy-git-701f4ed56639325dcb9fa0aecf06df303ee6a761.tar.gz |
Convert farm/run_chdir.py to a test_summary.py test
Diffstat (limited to 'tests')
-rw-r--r-- | tests/farm/run/run_chdir.py | 15 | ||||
-rw-r--r-- | tests/farm/run/src/chdir.py | 7 | ||||
-rw-r--r-- | tests/farm/run/src/subdir/placeholder | 0 | ||||
-rw-r--r-- | tests/test_summary.py | 14 |
4 files changed, 14 insertions, 22 deletions
diff --git a/tests/farm/run/run_chdir.py b/tests/farm/run/run_chdir.py deleted file mode 100644 index 5ec0b4ea..00000000 --- a/tests/farm/run/run_chdir.py +++ /dev/null @@ -1,15 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -copy("src", "out_chdir") -run(""" - coverage run chdir.py - coverage report - """, rundir="out_chdir", outfile="stdout.txt") -contains("out_chdir/stdout.txt", - "Line One", - "Line Two", - "chdir" - ) -doesnt_contain("out_chdir/stdout.txt", "No such file or directory") -clean("out_chdir") diff --git a/tests/farm/run/src/chdir.py b/tests/farm/run/src/chdir.py deleted file mode 100644 index 250f7132..00000000 --- a/tests/farm/run/src/chdir.py +++ /dev/null @@ -1,7 +0,0 @@ -# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0 -# For details: https://github.com/nedbat/coveragepy/blob/master/NOTICE.txt - -import os -print("Line One") -os.chdir("subdir") -print("Line Two") diff --git a/tests/farm/run/src/subdir/placeholder b/tests/farm/run/src/subdir/placeholder deleted file mode 100644 index e69de29b..00000000 --- a/tests/farm/run/src/subdir/placeholder +++ /dev/null diff --git a/tests/test_summary.py b/tests/test_summary.py index f0e8956e..93fab28f 100644 --- a/tests/test_summary.py +++ b/tests/test_summary.py @@ -580,6 +580,20 @@ class SummaryTest(UsingModulesMixin, CoverageTest): report = self.report_from_command("coverage report") self.assertEqual(self.last_line_squeezed(report), "xxx 7 1 86%") + def test_report_with_chdir(self): + self.make_file("chdir.py", """\ + import os + print("Line One") + os.chdir("subdir") + print("Line Two") + print(open("something").read()) + """) + self.make_file("subdir/something", "hello") + out = self.run_command("coverage run chdir.py") + self.assertEqual(out, "Line One\nLine Two\nhello\n") + report = self.report_from_command("coverage report") + self.assertEqual(self.last_line_squeezed(report), "chdir.py 5 0 100%") + def get_report(self, cov): """Get the report from `cov`, and canonicalize it.""" repout = StringIO() |