From fc38bf8526cb1717968a1958439da5fae4768375 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 19 Dec 2012 21:20:29 -0500 Subject: Retro-fit onto 2.3 and 2.4 again. --- test/test_process.py | 12 +++++++----- test/test_testing.py | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/test_process.py b/test/test_process.py index 6d1e1fd0..524d793e 100644 --- a/test/test_process.py +++ b/test/test_process.py @@ -462,17 +462,19 @@ class ProcessStartupTest(CoverageTest): def setUp(self): super(ProcessStartupTest, self).setUp() # Find a place to put a .pth file. + pth_contents = "import coverage; coverage.process_startup()\n" for d in sys.path: # pragma: part covered g = glob.glob(os.path.join(d, "*.pth")) if g: pth_path = os.path.join(d, "subcover.pth") pth = open(pth_path, "w") try: - pth.write("import coverage; coverage.process_startup()\n") - self.pth_path = pth_path - break - except (IOError, OSError): # pragma: not covered - pass + try: + pth.write(pth_contents) + self.pth_path = pth_path + break + except (IOError, OSError): # pragma: not covered + pass finally: pth.close() else: # pragma: not covered diff --git a/test/test_testing.py b/test/test_testing.py index c8672e49..fcbffcde 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -3,7 +3,7 @@ import os, sys sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k -from coverage.backward import to_bytes +from coverage.backward import to_bytes, rpartition from backunittest import TestCase from coveragetest import CoverageTest @@ -189,5 +189,5 @@ class CoverageTestTest(CoverageTest): executable = executable.split(":", 1)[1].strip() self.assertEqual(executable, sys.executable) environ = [l for l in out if "COV_FOOBAR" in l][0] - _, _, environ = environ.rpartition(":") + _, _, environ = rpartition(environ, ":") self.assertEqual(environ.strip(), "COV_FOOBAR = XYZZY") -- cgit v1.2.1