diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-17 07:37:45 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2019-12-17 07:37:45 -0500 |
commit | 53ae55e053a4e7358a5708b2c194d26851690439 (patch) | |
tree | f79f36bd9aee29e095b8b8cae04eac074113e043 | |
parent | 842f5854e75362214ce4699d8707ccc81601900a (diff) | |
download | python-coveragepy-git-53ae55e053a4e7358a5708b2c194d26851690439.tar.gz |
Combine test helpers: remove_files
-rw-r--r-- | tests/helpers.py | 11 | ||||
-rw-r--r-- | tests/test_concurrency.py | 7 |
2 files changed, 9 insertions, 9 deletions
diff --git a/tests/helpers.py b/tests/helpers.py index bc9c3982..09ba485d 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -4,7 +4,6 @@ """Helpers for coverage.py tests.""" import glob -import itertools import os import re import shutil @@ -106,6 +105,13 @@ def re_line(text, pat): return lines[0] +def remove_files(*patterns): + """Remove all files that match any of the patterns.""" + for pattern in patterns: + for fname in glob.glob(pattern): + os.remove(fname) + + class SuperModuleCleaner(ModuleCleaner): """Remember the state of sys.modules and restore it later.""" @@ -122,8 +128,7 @@ class SuperModuleCleaner(ModuleCleaner): # Also have to clean out the .pyc file, since the timestamp # resolution is only one second, a changed file might not be # picked up. - for pyc in itertools.chain(glob.glob('*.pyc'), glob.glob('*$py.class')): - os.remove(pyc) + remove_files("*.pyc", "*$py.class") if os.path.exists("__pycache__"): shutil.rmtree("__pycache__") diff --git a/tests/test_concurrency.py b/tests/test_concurrency.py index 5d492a72..436df803 100644 --- a/tests/test_concurrency.py +++ b/tests/test_concurrency.py @@ -19,6 +19,7 @@ from coverage.data import line_counts from coverage.files import abs_file from tests.coveragetest import CoverageTest +from tests.helpers import remove_files # These libraries aren't always available, we'll skip tests if they aren't. @@ -361,12 +362,6 @@ MULTI_CODE = """ """ -def remove_files(*patterns): - for pattern in patterns: - for fname in glob.glob(pattern): - os.remove(fname) - - @flaky(max_runs=30) # Sometimes a test fails due to inherent randomness. Try more times. class MultiprocessingTest(CoverageTest): """Test support of the multiprocessing module.""" |