Skip to content

Commit d10e03c

Browse files
committed
A test of running coverage when it has been zipped. #862
1 parent d197d9c commit d10e03c

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ setuptools-*.egg
3131
.ruby-version
3232

3333
# Stuff in the test directory.
34+
covmain.zip
3435
zipmods.zip
3536

3637
# Stuff in the doc directory.

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Frazer McLean
5858
Geoff Bache
5959
George Paci
6060
George Song
61+
George-Cristian Bîrzan
6162
Greg Rogers
6263
Guido van Rossum
6364
Guillaume Chazarain

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ clean: clean_platform ## Remove artifacts of test execution, i
2424
rm -f .coverage .coverage.* coverage.xml .metacov*
2525
rm -f .tox/*/lib/*/site-packages/zzz_metacov.pth
2626
rm -f */.coverage */*/.coverage */*/*/.coverage */*/*/*/.coverage */*/*/*/*/.coverage */*/*/*/*/*/.coverage
27-
rm -f tests/zipmods.zip
27+
rm -f tests/covmain.zip tests/zipmods.zip
2828
rm -rf tests/eggsrc/build tests/eggsrc/dist tests/eggsrc/*.egg-info
2929
rm -f setuptools-*.egg distribute-*.egg distribute-*.tar.gz
3030
rm -rf doc/_build doc/_spell doc/sample_html_beta

igor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ def do_zip_mods():
225225

226226
zf.close()
227227

228+
zf = zipfile.ZipFile("tests/covmain.zip", "w")
229+
zf.write("coverage/__main__.py", "__main__.py")
230+
zf.close()
231+
228232

229233
def do_install_egg():
230234
"""Install the egg1 egg for tests."""

tests/test_process.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from coverage.files import python_reported_file
2424
from coverage.misc import output_encoding
2525

26-
from tests.coveragetest import CoverageTest
26+
from tests.coveragetest import CoverageTest, TESTS_DIR
2727
from tests.helpers import re_lines
2828

2929

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

975+
def test_coverage_zip_is_like_python(self):
976+
# Test running coverage from a zip file itself. Some environments
977+
# (windows?) zip up the coverage main to be used as the coverage
978+
# command.
979+
with open(TRY_EXECFILE) as f:
980+
self.make_file("run_me.py", f.read())
981+
expected = self.run_command("python run_me.py")
982+
cov_main = os.path.join(TESTS_DIR, "covmain.zip")
983+
actual = self.run_command("python {} run run_me.py".format(cov_main))
984+
self.assert_tryexecfile_output(expected, actual)
985+
975986
def test_coverage_custom_script(self):
976987
# https://github.com/nedbat/coveragepy/issues/678
977988
# If sys.path[0] isn't the Python default, then coverage.py won't

0 commit comments

Comments
 (0)