Skip to content

Commit

Permalink
A test that reproduces #862
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Jan 9, 2020
1 parent e4b8389 commit 698bf4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS.txt
Expand Up @@ -11,6 +11,7 @@ Alex Gaynor
Alex Groce
Alex Sandro
Alexander Todorov
Alexander Walters
Andrew Hoos
Anthony Sottile
Arcadiy Ivanov
Expand Down
18 changes: 18 additions & 0 deletions tests/test_process.py
Expand Up @@ -9,6 +9,7 @@
import os
import os.path
import re
import stat
import sys
import textwrap
import time
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 698bf4d

Please sign in to comment.