Skip to content

Commit

Permalink
A test of running coverage when it has been zipped. #862
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jan 10, 2020
1 parent 22b22e6 commit d0a7b5a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ setuptools-*.egg
.ruby-version

# Stuff in the test directory.
covmain.zip
zipmods.zip

# Stuff in the doc directory.
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Frazer McLean
Geoff Bache
George Paci
George Song
George-Cristian Bîrzan
Greg Rogers
Guido van Rossum
Guillaume Chazarain
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ clean: clean_platform ## Remove artifacts of test execution, i
rm -f .coverage .coverage.* coverage.xml .metacov*
rm -f .tox/*/lib/*/site-packages/zzz_metacov.pth
rm -f */.coverage */*/.coverage */*/*/.coverage */*/*/*/.coverage */*/*/*/*/.coverage */*/*/*/*/*/.coverage
rm -f tests/zipmods.zip
rm -f tests/covmain.zip tests/zipmods.zip
rm -rf tests/eggsrc/build tests/eggsrc/dist tests/eggsrc/*.egg-info
rm -f setuptools-*.egg distribute-*.egg distribute-*.tar.gz
rm -rf doc/_build doc/_spell doc/sample_html_beta
Expand Down
4 changes: 4 additions & 0 deletions igor.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ def do_zip_mods():

zf.close()

zf = zipfile.ZipFile("tests/covmain.zip", "w")
zf.write("coverage/__main__.py", "__main__.py")
zf.close()


def do_install_egg():
"""Install the egg1 egg for tests."""
Expand Down
13 changes: 12 additions & 1 deletion tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from coverage.files import python_reported_file
from coverage.misc import output_encoding

from tests.coveragetest import CoverageTest
from tests.coveragetest import CoverageTest, TESTS_DIR
from tests.helpers import re_lines


Expand Down Expand Up @@ -972,6 +972,17 @@ def test_coverage_run_dashm_is_like_python_dashm_with__main__207(self):
actual = self.run_command("coverage run -m package")
self.assertMultiLineEqual(expected, actual)

def test_coverage_zip_is_like_python(self):
# Test running coverage from a zip file itself. Some environments
# (windows?) zip up the coverage main to be used as the coverage
# command.
with open(TRY_EXECFILE) as f:
self.make_file("run_me.py", f.read())
expected = self.run_command("python run_me.py")
cov_main = os.path.join(TESTS_DIR, "covmain.zip")
actual = self.run_command("python {} run run_me.py".format(cov_main))
self.assert_tryexecfile_output(expected, actual)

def test_coverage_custom_script(self):
# https://github.com/nedbat/coveragepy/issues/678
# If sys.path[0] isn't the Python default, then coverage.py won't
Expand Down

0 comments on commit d0a7b5a

Please sign in to comment.