summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-01-09 08:52:38 -0500
committerNed Batchelder <ned@nedbatchelder.com>2020-01-11 07:15:04 -0500
commitd10e03c4347198f6f04cf31103cee53cd02f2ee0 (patch)
tree80ba8ebddce524c0230568ce16ee47eb394db87d
parentd197d9cc6fbfd934d3c96629f43e1354e383f5a8 (diff)
downloadpython-coveragepy-git-d10e03c4347198f6f04cf31103cee53cd02f2ee0.tar.gz
A test of running coverage when it has been zipped. #862
-rw-r--r--.gitignore1
-rw-r--r--CONTRIBUTORS.txt1
-rw-r--r--Makefile2
-rw-r--r--igor.py4
-rw-r--r--tests/test_process.py13
5 files changed, 19 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 1b96396a..971e9b84 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ setuptools-*.egg
.ruby-version
# Stuff in the test directory.
+covmain.zip
zipmods.zip
# Stuff in the doc directory.
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 9894c43b..4cb09b6a 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -58,6 +58,7 @@ Frazer McLean
Geoff Bache
George Paci
George Song
+George-Cristian Bîrzan
Greg Rogers
Guido van Rossum
Guillaume Chazarain
diff --git a/Makefile b/Makefile
index 449271a9..368a07ec 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/igor.py b/igor.py
index 56674c06..a742cb8e 100644
--- a/igor.py
+++ b/igor.py
@@ -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."""
diff --git a/tests/test_process.py b/tests/test_process.py
index ec6662c2..6ca4571c 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -23,7 +23,7 @@ from coverage.data import line_counts
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
@@ -972,6 +972,17 @@ class EnvironmentTest(CoverageTest):
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