diff options
-rw-r--r-- | coverage/backward.py | 2 | ||||
-rw-r--r-- | coverage/results.py | 2 | ||||
-rw-r--r-- | test/test_testing.py | 10 |
3 files changed, 9 insertions, 5 deletions
diff --git a/coverage/backward.py b/coverage/backward.py index 1217e9ef..c363f21f 100644 --- a/coverage/backward.py +++ b/coverage/backward.py @@ -75,7 +75,7 @@ except ImportError: # Python 3.2 provides `tokenize.open`, the best way to open source files. try: import tokenize - open_source = tokenize.open + open_source = tokenize.open # pylint: disable=E1101 except AttributeError: def open_source(fname): """Open a source file the best way.""" diff --git a/coverage/results.py b/coverage/results.py index 6cc49cd3..a7ec0fdc 100644 --- a/coverage/results.py +++ b/coverage/results.py @@ -230,4 +230,4 @@ class Numbers(object): # Implementing 0+Numbers allows us to sum() a list of Numbers. if other == 0: return self - raise NotImplemented + return NotImplemented diff --git a/test/test_testing.py b/test/test_testing.py index 66a4093c..2461a08e 100644 --- a/test/test_testing.py +++ b/test/test_testing.py @@ -96,6 +96,10 @@ class TestingTest(TestCase): class CoverageTestTest(CoverageTest): """Test the methods in `CoverageTest`.""" + def file_text(self, fname): + """Return the text read from a file.""" + return open(fname, "rb").read().decode('ascii') + def test_make_file(self): # A simple file. self.make_file("fooey.boo", "Hello there") @@ -112,8 +116,8 @@ class CoverageTestTest(CoverageTest): def test_make_file_newline(self): self.make_file("unix.txt", "Hello\n") - self.assertEqual(open("unix.txt", "rb").read().decode('ascii'), "Hello\n") + self.assertEqual(self.file_text("unix.txt"), "Hello\n") self.make_file("dos.txt", "Hello\n", newline="\r\n") - self.assertEqual(open("dos.txt", "rb").read().decode('ascii'), "Hello\r\n") + self.assertEqual(self.file_text("dos.txt"), "Hello\r\n") self.make_file("mac.txt", "Hello\n", newline="\r") - self.assertEqual(open("mac.txt", "rb").read().decode('ascii'), "Hello\r") + self.assertEqual(self.file_text("mac.txt"), "Hello\r") |