diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-09 18:18:02 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-07-09 18:18:02 -0400 |
commit | 9dee319c84c52c8e9201e1eb919bc919668366e6 (patch) | |
tree | 7115028ad625e5065da24f5a4b55bb53c1d417d1 | |
parent | 221822595b4e040c66937a3f9574623a9756b736 (diff) | |
download | python-coveragepy-git-9dee319c84c52c8e9201e1eb919bc919668366e6.tar.gz |
Py3k: some output is bytes instead of string, so convert since it doesn't matter.
-rw-r--r-- | coverage/backward.py | 11 | ||||
-rw-r--r-- | test/test_coverage.py | 8 | ||||
-rw-r--r-- | test/test_farm.py | 2 |
3 files changed, 14 insertions, 7 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 7ee1e406..8576bbf3 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -46,7 +46,7 @@ else: if sys.hexversion > 0x03000000 and cmd.startswith("coverage "): # We don't have a coverage command on 3.x, so fix it up to call the - # script. + # script. Eventually we won't need this. cmd = "python " + sys.prefix + os.sep + "Scripts" + os.sep + cmd proc = subprocess.Popen(cmd, shell=True, @@ -54,4 +54,11 @@ else: stderr=subprocess.STDOUT ) retcode = proc.wait() - return retcode, proc.stdout.read() + + # Get the output, and canonicalize it to strings with newlines. + output = proc.stdout.read() + if not isinstance(output, str): + output = output.decode('utf-8') + output = output.replace('\r', '') + + return retcode, output diff --git a/test/test_coverage.py b/test/test_coverage.py index d1c6cf21..7ff5b4c0 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -1619,7 +1619,7 @@ class ProcessTest(CoverageTest): self.assert_(not os.path.exists(".coverage")) out = self.run_command("coverage -x mycode.py") self.assert_(os.path.exists(".coverage")) - self.assertEqual(out.strip(), 'done') + self.assertEqual(out, 'done\n') def testReport(self): self.makeFile("mycode.py", """\ @@ -1630,7 +1630,7 @@ class ProcessTest(CoverageTest): """) out = self.run_command("coverage -x mycode.py") - self.assertEqual(out.strip(), 'done') + self.assertEqual(out, 'done\n') report1 = self.run_command("coverage -r").replace('\\', '/') # Name Stmts Exec Cover @@ -1689,11 +1689,11 @@ class ProcessTest(CoverageTest): """) out = self.run_command("coverage -x -p b_or_c.py b") - self.assertEqual(out.strip(), 'done') + self.assertEqual(out, 'done\n') self.assert_(not os.path.exists(".coverage")) out = self.run_command("coverage -x -p b_or_c.py c") - self.assertEqual(out.strip(), 'done') + self.assertEqual(out, 'done\n') self.assert_(not os.path.exists(".coverage")) # After two -p runs, there should be two .coverage.machine.123 files. diff --git a/test/test_farm.py b/test/test_farm.py index 239dac00..6e8f3467 100644 --- a/test/test_farm.py +++ b/test/test_farm.py @@ -135,7 +135,7 @@ class FarmTestCase(object): retcode, output = run_command(cmd) print output, if outfile: - open(outfile, "a+").write(output.decode('utf-8')) + open(outfile, "a+").write(output) if retcode: raise Exception("command exited abnormally") finally: |