diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-05 13:21:16 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2013-10-05 13:21:16 -0400 |
commit | 554ae8ae796348fb1a3e439967f0ef740b46772e (patch) | |
tree | 69472d886e8a61c9c9500ade39bf1712e7ddd5b4 /tests/test_testing.py | |
parent | b9b08877c2c1c99b181a3e23a2e35e4ea0ff320c (diff) | |
download | python-coveragepy-554ae8ae796348fb1a3e439967f0ef740b46772e.tar.gz |
Make everything work on py2.3 again (for the last time).
Diffstat (limited to 'tests/test_testing.py')
-rw-r--r-- | tests/test_testing.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py index 06f2eb0..c56d811 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -186,7 +186,34 @@ class CoverageTestTest(CoverageTest): # "environment: COV_FOOBAR = XYZZY" or "COV_FOOBAR = XYZZY" executable = [l for l in out if "executable:" in l][0] executable = executable.split(":", 1)[1].strip() - self.assertEqual(executable, sys.executable) + self.assertTrue(same_python_executable(executable, sys.executable)) environ = [l for l in out if "COV_FOOBAR" in l][0] _, _, environ = rpartition(environ, ":") self.assertEqual(environ.strip(), "COV_FOOBAR = XYZZY") + + +def same_python_executable(e1, e2): + """Determine if `e1` and `e2` refer to the same Python executable. + + Either path could include symbolic links. The two paths might not refer + to the exact same file, but if they are in the same directory and their + numeric suffixes aren't different, they are the same executable. + + """ + e1 = os.path.abspath(os.path.realpath(e1)) + e2 = os.path.abspath(os.path.realpath(e2)) + + if os.path.dirname(e1) != os.path.dirname(e2): + return False + + e1 = os.path.basename(e1) + e2 = os.path.basename(e2) + + if e1 == "python" or e2 == "python" or e1 == e2: + # python and python2.3: ok + # python2.3 and python: ok + # python and python: ok + # python2.3 and python2.3: ok + return True + + return False |