summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2020-01-08 20:06:20 -0500
committerNed Batchelder <ned@nedbatchelder.com>2020-01-10 07:31:34 -0500
commitd197d9cc6fbfd934d3c96629f43e1354e383f5a8 (patch)
treef0d360f0782ad0643bd60642252f3153154041f8
parent648b136e67caa01742363f5a4224288c5703cdee (diff)
downloadpython-coveragepy-git-d197d9cc6fbfd934d3c96629f43e1354e383f5a8.tar.gz
A test that reproduces #862
-rw-r--r--CONTRIBUTORS.txt1
-rw-r--r--tests/test_process.py18
2 files changed, 19 insertions, 0 deletions
diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt
index 228973a6..9894c43b 100644
--- a/CONTRIBUTORS.txt
+++ b/CONTRIBUTORS.txt
@@ -11,6 +11,7 @@ Alex Gaynor
Alex Groce
Alex Sandro
Alexander Todorov
+Alexander Walters
Andrew Hoos
Anthony Sottile
Arcadiy Ivanov
diff --git a/tests/test_process.py b/tests/test_process.py
index 9aade773..ec6662c2 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -9,6 +9,7 @@ import glob
import os
import os.path
import re
+import stat
import sys
import textwrap
import time
@@ -1004,6 +1005,23 @@ class EnvironmentTest(CoverageTest):
out = self.run_command("python -m run_coverage run how_is_it.py")
self.assertIn("hello-xyzzy", out)
+ def test_bug_862(self):
+ if env.WINDOWS:
+ self.skipTest("Windows can't make symlinks")
+ # This simulates how pyenv and pyenv-virtualenv end up creating the
+ # coverage executable.
+ self.make_file("elsewhere/bin/fake-coverage", """\
+ #!{executable}
+ import sys, pkg_resources
+ sys.exit(pkg_resources.load_entry_point('coverage', 'console_scripts', 'coverage')())
+ """.format(executable=sys.executable))
+ os.chmod("elsewhere/bin/fake-coverage", stat.S_IREAD | stat.S_IEXEC)
+ os.symlink("elsewhere", "somewhere")
+ self.make_file("foo.py", "print('inside foo')")
+ self.make_file("bar.py", "import foo")
+ out = self.run_command("somewhere/bin/fake-coverage run bar.py")
+ self.assertEqual("inside foo\n", out)
+
def test_bug_909(self):
# https://github.com/nedbat/coveragepy/issues/909
# The __init__ files were being imported before measurement started,