Skip to content

Commit d402b46

Browse files
committed
A test replicating #916
1 parent a4cda16 commit d402b46

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/test_api.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,21 +998,24 @@ class TestRunnerPluginTest(CoverageTest):
998998
way they do.
999999
10001000
"""
1001-
def pretend_to_be_nose_with_cover(self, erase):
1001+
def pretend_to_be_nose_with_cover(self, erase=False, cd=False):
10021002
"""This is what the nose --with-cover plugin does."""
10031003
self.make_file("no_biggie.py", """\
10041004
a = 1
10051005
b = 2
10061006
if b == 1:
10071007
c = 4
10081008
""")
1009+
self.make_file("sub/hold.txt", "")
10091010

10101011
cov = coverage.Coverage()
10111012
if erase:
10121013
cov.combine()
10131014
cov.erase()
10141015
cov.load()
10151016
self.start_import_stop(cov, "no_biggie")
1017+
if cd:
1018+
os.chdir("sub")
10161019
cov.combine()
10171020
cov.save()
10181021
cov.report(["no_biggie.py"], show_missing=True)
@@ -1021,13 +1024,19 @@ def pretend_to_be_nose_with_cover(self, erase):
10211024
--------------------------------------------
10221025
no_biggie.py 4 1 75% 4
10231026
"""))
1027+
if cd:
1028+
os.chdir("..")
10241029

10251030
def test_nose_plugin(self):
1026-
self.pretend_to_be_nose_with_cover(erase=False)
1031+
self.pretend_to_be_nose_with_cover()
10271032

10281033
def test_nose_plugin_with_erase(self):
10291034
self.pretend_to_be_nose_with_cover(erase=True)
10301035

1036+
def test_nose_plugin_with_cd(self):
1037+
# https://github.com/nedbat/coveragepy/issues/916
1038+
self.pretend_to_be_nose_with_cover(cd=True)
1039+
10311040
def pretend_to_be_pytestcov(self, append):
10321041
"""Act like pytest-cov."""
10331042
self.make_file("prog.py", """\

0 commit comments

Comments
 (0)