diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index 228973a60..9894c43bb 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 9aade773d..ec6662c2e 100644 --- a/tests/test_process.py +++ b/tests/test_process.py @@ -9,6 +9,7 @@ import os import os.path import re +import stat import sys import textwrap import time @@ -1004,6 +1005,23 @@ def test_coverage_custom_script(self): 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,