From 6c8ccb13e0dc78bed148fb0c1626e93429704a30 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Mon, 9 Aug 2021 16:36:14 -0400 Subject: [PATCH] test: a part-covered comprehension The comprehension would only completely finish (->exit) if the assert was going to fail. So we expect it to not finish. --- metacov.ini | 1 - tests/test_execfile.py | 4 +--- tests/test_plugins.py | 3 ++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/metacov.ini b/metacov.ini index 209c12121..fa6887e25 100644 --- a/metacov.ini +++ b/metacov.ini @@ -78,7 +78,6 @@ partial_branches = pragma: part covered # A for-loop that always hits its break statement pragma: always breaks - pragma: if failure pragma: part started if env.TESTING: if env.METACOV: diff --git a/tests/test_execfile.py b/tests/test_execfile.py index fe02f5fe2..c0ed2d482 100644 --- a/tests/test_execfile.py +++ b/tests/test_execfile.py @@ -4,13 +4,11 @@ """Tests for coverage.execfile""" import compileall -import fnmatch import json import os import os.path import pathlib import re -import sys import pytest @@ -107,7 +105,7 @@ def test_directory_without_main(self): class RunPycFileTest(CoverageTest): """Test cases for `run_python_file`.""" - def make_pyc(self): # pylint: disable=inconsistent-return-statements + def make_pyc(self): """Create a .pyc file, and return the path to it.""" if env.JYTHON: pytest.skip("Can't make .pyc files on Jython") diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 18c085077..ecc464ccf 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -657,7 +657,8 @@ def run_bad_plugin(self, module_name, plugin_name, our_error=True, excmsg=None, if excmsg: assert excmsg in stderr if excmsgs: - assert any(em in stderr for em in excmsgs), f"expected one of {excmsgs} in stderr" + found_exc = any(em in stderr for em in excmsgs) # pragma: part covered + assert found_exc, f"expected one of {excmsgs} in stderr" def test_file_tracer_has_no_file_tracer_method(self): self.make_file("bad_plugin.py", """\