summaryrefslogtreecommitdiff
path: root/tests/test_testing.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2013-10-05 13:21:16 -0400
committerNed Batchelder <ned@nedbatchelder.com>2013-10-05 13:21:16 -0400
commit7599c0d495353607155f336c8c7a9850f8ad4f55 (patch)
treeb79f345105791f836d3a6deb73550db44731b15c /tests/test_testing.py
parent9c308678f4043a093503df1770caf8bc9d6bec9d (diff)
downloadpython-coveragepy-git-7599c0d495353607155f336c8c7a9850f8ad4f55.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.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py
index 06f2eb01..c56d8110 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