Skip to content

Commit

Permalink
A test replicating #916
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jan 8, 2020
1 parent a4cda16 commit d402b46
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -998,21 +998,24 @@ class TestRunnerPluginTest(CoverageTest):
way they do.
"""
def pretend_to_be_nose_with_cover(self, erase):
def pretend_to_be_nose_with_cover(self, erase=False, cd=False):
"""This is what the nose --with-cover plugin does."""
self.make_file("no_biggie.py", """\
a = 1
b = 2
if b == 1:
c = 4
""")
self.make_file("sub/hold.txt", "")

cov = coverage.Coverage()
if erase:
cov.combine()
cov.erase()
cov.load()
self.start_import_stop(cov, "no_biggie")
if cd:
os.chdir("sub")
cov.combine()
cov.save()
cov.report(["no_biggie.py"], show_missing=True)
Expand All @@ -1021,13 +1024,19 @@ def pretend_to_be_nose_with_cover(self, erase):
--------------------------------------------
no_biggie.py 4 1 75% 4
"""))
if cd:
os.chdir("..")

def test_nose_plugin(self):
self.pretend_to_be_nose_with_cover(erase=False)
self.pretend_to_be_nose_with_cover()

def test_nose_plugin_with_erase(self):
self.pretend_to_be_nose_with_cover(erase=True)

def test_nose_plugin_with_cd(self):
# https://github.com/nedbat/coveragepy/issues/916
self.pretend_to_be_nose_with_cover(cd=True)

def pretend_to_be_pytestcov(self, append):
"""Act like pytest-cov."""
self.make_file("prog.py", """\
Expand Down

0 comments on commit d402b46

Please sign in to comment.