summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-02-22 06:38:12 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-02-22 06:38:12 -0500
commit917c250a9afb2d9d7675131974ff3dbec5bf355e (patch)
tree1f5413fdf8f72c6a077dea337b21ae8291274777
parent728196ff86a5d616fe26038c5932fd35de89f9ad (diff)
downloadpython-coveragepy-917c250a9afb2d9d7675131974ff3dbec5bf355e.tar.gz
More pragmas to fine-tune coverage of test code
-rw-r--r--metacov.ini4
-rw-r--r--tests/test_concurrency.py22
-rw-r--r--tests/test_process.py4
3 files changed, 17 insertions, 13 deletions
diff --git a/metacov.ini b/metacov.ini
index 55d0225..eebfc0f 100644
--- a/metacov.ini
+++ b/metacov.ini
@@ -35,6 +35,10 @@ exclude_lines =
# OS error conditions that we can't (or don't care to) replicate.
pragma: cant happen
+ # Obscure bugs in specific versions of interpreters, and so probably no
+ # longer tested.
+ pragma: obscure
+
# Jython needs special care.
pragma: only jython
skip.*Jython
diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py
index 76e1d9e..88f2b50 100644
--- a/tests/test_concurrency.py
+++ b/tests/test_concurrency.py
@@ -464,7 +464,7 @@ def test_coverage_stop_in_threads():
has_started_coverage = []
has_stopped_coverage = []
- def run_thread():
+ def run_thread(): # pragma: nested
"""Check that coverage is stopping properly in threads."""
deadline = time.time() + 5
ident = threading.currentThread().ident
@@ -480,11 +480,11 @@ def test_coverage_stop_in_threads():
cov = coverage.coverage()
cov.start()
- t = threading.Thread(target=run_thread)
- t.start()
+ t = threading.Thread(target=run_thread) # pragma: nested
+ t.start() # pragma: nested
- time.sleep(0.1)
- cov.stop()
+ time.sleep(0.1) # pragma: nested
+ cov.stop() # pragma: nested
time.sleep(0.1)
assert has_started_coverage == [t.ident]
@@ -513,7 +513,7 @@ def test_thread_safe_save_data(tmpdir):
for module_name in module_names:
import_local_file(module_name)
- def random_load():
+ def random_load(): # pragma: nested
"""Import modules randomly to stress coverage."""
while should_run[0]:
module_name = random.choice(module_names)
@@ -529,12 +529,12 @@ def test_thread_safe_save_data(tmpdir):
cov = coverage.coverage()
cov.start()
- threads = [threading.Thread(target=random_load) for _ in range(10)]
- should_run[0] = True
- for t in threads:
+ threads = [threading.Thread(target=random_load) for _ in range(10)] # pragma: nested
+ should_run[0] = True # pragma: nested
+ for t in threads: # pragma: nested
t.start()
- time.sleep(duration)
+ time.sleep(duration) # pragma: nested
cov.stop()
@@ -546,7 +546,7 @@ def test_thread_safe_save_data(tmpdir):
for t in threads:
t.join()
- if (not imported) and duration < 10:
+ if (not imported) and duration < 10: # pragma: only failure
duration *= 2
finally:
diff --git a/tests/test_process.py b/tests/test_process.py
index 85adcf4..2cabe0b 100644
--- a/tests/test_process.py
+++ b/tests/test_process.py
@@ -610,7 +610,7 @@ class ProcessTest(CoverageTest):
self.assertIn(msg, out)
def test_note(self):
- if env.PYPY and env.PY3 and env.PYPYVERSION[:3] == (5, 10, 0):
+ if env.PYPY and env.PY3 and env.PYPYVERSION[:3] == (5, 10, 0): # pragma: obscure
# https://bitbucket.org/pypy/pypy/issues/2729/pypy3-510-incorrectly-decodes-astral-plane
self.skipTest("Avoid incorrect decoding astral plane JSON chars")
self.make_file(".coveragerc", """\
@@ -767,7 +767,7 @@ class EnvironmentTest(CoverageTest):
self.assert_tryexecfile_output(out_cov, out_py)
def test_coverage_run_dir_is_like_python_dir(self):
- if sys.version_info == (3, 5, 4, 'final', 0): # pragma: not covered
+ if sys.version_info == (3, 5, 4, 'final', 0): # pragma: obscure
self.skipTest("3.5.4 broke this: https://bugs.python.org/issue32551")
with open(TRY_EXECFILE) as f:
self.make_file("with_main/__main__.py", f.read())