Skip to content

Commit d197d9c

Browse files
committed
A test that reproduces #862
1 parent 648b136 commit d197d9c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CONTRIBUTORS.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Alex Gaynor
1111
Alex Groce
1212
Alex Sandro
1313
Alexander Todorov
14+
Alexander Walters
1415
Andrew Hoos
1516
Anthony Sottile
1617
Arcadiy Ivanov

tests/test_process.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import os
1010
import os.path
1111
import re
12+
import stat
1213
import sys
1314
import textwrap
1415
import time
@@ -1004,6 +1005,23 @@ def test_coverage_custom_script(self):
10041005
out = self.run_command("python -m run_coverage run how_is_it.py")
10051006
self.assertIn("hello-xyzzy", out)
10061007

1008+
def test_bug_862(self):
1009+
if env.WINDOWS:
1010+
self.skipTest("Windows can't make symlinks")
1011+
# This simulates how pyenv and pyenv-virtualenv end up creating the
1012+
# coverage executable.
1013+
self.make_file("elsewhere/bin/fake-coverage", """\
1014+
#!{executable}
1015+
import sys, pkg_resources
1016+
sys.exit(pkg_resources.load_entry_point('coverage', 'console_scripts', 'coverage')())
1017+
""".format(executable=sys.executable))
1018+
os.chmod("elsewhere/bin/fake-coverage", stat.S_IREAD | stat.S_IEXEC)
1019+
os.symlink("elsewhere", "somewhere")
1020+
self.make_file("foo.py", "print('inside foo')")
1021+
self.make_file("bar.py", "import foo")
1022+
out = self.run_command("somewhere/bin/fake-coverage run bar.py")
1023+
self.assertEqual("inside foo\n", out)
1024+
10071025
def test_bug_909(self):
10081026
# https://github.com/nedbat/coveragepy/issues/909
10091027
# The __init__ files were being imported before measurement started,

0 commit comments

Comments
 (0)