From 701f4ed56639325dcb9fa0aecf06df303ee6a761 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 18 Nov 2018 10:49:58 -0500 Subject: Convert farm/run_chdir.py to a test_summary.py test --- tests/test_summary.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/test_summary.py') 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() -- cgit v1.2.1