diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-28 19:44:20 -0400 |
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2014-09-28 19:44:20 -0400 |
| commit | 9453fa062539ac28b60c325e39c0fcbfd3b2ea10 (patch) | |
| tree | be81d9b59be8c0c9a3b4a4ae59c047df2d332d8b /tests | |
| parent | f8455cc745ccbde7ee1cc13bd302a7bdc3369d6c (diff) | |
| download | python-coveragepy-git-9453fa062539ac28b60c325e39c0fcbfd3b2ea10.tar.gz | |
Pragmas for uncovered code
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/coveragetest.py | 9 | ||||
| -rw-r--r-- | tests/test_execfile.py | 4 | ||||
| -rw-r--r-- | tests/test_farm.py | 7 | ||||
| -rw-r--r-- | tests/test_templite.py | 6 | ||||
| -rw-r--r-- | tests/test_testing.py | 4 |
5 files changed, 16 insertions, 14 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 4053059f..19fc0612 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -37,10 +37,11 @@ class CoverageTest( def setUp(self): super(CoverageTest, self).setUp() - if _TEST_NAME_FILE: - f = open(_TEST_NAME_FILE, "w") - f.write("%s_%s" % (self.__class__.__name__, self._testMethodName)) - f.close() + if _TEST_NAME_FILE: # pragma: debugging + with open(_TEST_NAME_FILE, "w") as f: + f.write("%s_%s" % ( + self.__class__.__name__, self._testMethodName, + )) def clean_local_file_imports(self): """Clean up the results of calls to `import_local_file`. diff --git a/tests/test_execfile.py b/tests/test_execfile.py index 69616e84..3a92ff76 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -91,9 +91,9 @@ class RunPycFileTest(CoverageTest): os.remove("compiled.py") # Find the .pyc file! - for there, _, files in os.walk("."): + for there, _, files in os.walk("."): # pragma: part covered for f in files: - if f.endswith(".pyc"): + if f.endswith(".pyc"): # pragma: part covered return os.path.join(there, f) def test_running_pyc(self): diff --git a/tests/test_farm.py b/tests/test_farm.py index 47f9b7b7..d0f0a72a 100644 --- a/tests/test_farm.py +++ b/tests/test_farm.py @@ -70,10 +70,9 @@ class FarmTestCase(object): """Execute the test from the run.py file. """ - if _TEST_NAME_FILE: - f = open(_TEST_NAME_FILE, "w") - f.write(self.description.replace("/", "_")) - f.close() + if _TEST_NAME_FILE: # pragma: debugging + with open(_TEST_NAME_FILE, "w") as f: + f.write(self.description.replace("/", "_")) cwd = self.cd(self.dir) diff --git a/tests/test_templite.py b/tests/test_templite.py index a4667a62..aa697b78 100644 --- a/tests/test_templite.py +++ b/tests/test_templite.py @@ -31,8 +31,10 @@ class TempliteTest(CoverageTest): an exception and never get to the result comparison. """ actual = Templite(text).render(ctx or {}) - if result: - self.assertEqual(actual, result) + # If result is None, then an exception should have prevented us getting + # to here. + assert result is not None + self.assertEqual(actual, result) def assertSynErr(self, msg): """Assert that a `TempliteSyntaxError` will happen. diff --git a/tests/test_testing.py b/tests/test_testing.py index 4a19098f..05db7298 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -114,7 +114,7 @@ def same_python_executable(e1, e2): e2 = os.path.abspath(os.path.realpath(e2)) if os.path.dirname(e1) != os.path.dirname(e2): - return False + return False # pragma: only failure e1 = os.path.basename(e1) e2 = os.path.basename(e2) @@ -126,4 +126,4 @@ def same_python_executable(e1, e2): # python2.3 and python2.3: ok return True - return False + return False # pragma: only failure |
