File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 4
4
"""Helpers for coverage.py tests."""
5
5
6
6
import glob
7
- import itertools
8
7
import os
9
8
import re
10
9
import shutil
@@ -106,6 +105,13 @@ def re_line(text, pat):
106
105
return lines [0 ]
107
106
108
107
108
+ def remove_files (* patterns ):
109
+ """Remove all files that match any of the patterns."""
110
+ for pattern in patterns :
111
+ for fname in glob .glob (pattern ):
112
+ os .remove (fname )
113
+
114
+
109
115
class SuperModuleCleaner (ModuleCleaner ):
110
116
"""Remember the state of sys.modules and restore it later."""
111
117
@@ -122,8 +128,7 @@ def clean_local_file_imports(self):
122
128
# Also have to clean out the .pyc file, since the timestamp
123
129
# resolution is only one second, a changed file might not be
124
130
# picked up.
125
- for pyc in itertools .chain (glob .glob ('*.pyc' ), glob .glob ('*$py.class' )):
126
- os .remove (pyc )
131
+ remove_files ("*.pyc" , "*$py.class" )
127
132
if os .path .exists ("__pycache__" ):
128
133
shutil .rmtree ("__pycache__" )
129
134
Original file line number Diff line number Diff line change 19
19
from coverage .files import abs_file
20
20
21
21
from tests .coveragetest import CoverageTest
22
+ from tests .helpers import remove_files
22
23
23
24
24
25
# These libraries aren't always available, we'll skip tests if they aren't.
@@ -361,12 +362,6 @@ def process_worker_main(args):
361
362
"""
362
363
363
364
364
- def remove_files (* patterns ):
365
- for pattern in patterns :
366
- for fname in glob .glob (pattern ):
367
- os .remove (fname )
368
-
369
-
370
365
@flaky (max_runs = 30 ) # Sometimes a test fails due to inherent randomness. Try more times.
371
366
class MultiprocessingTest (CoverageTest ):
372
367
"""Test support of the multiprocessing module."""
You can’t perform that action at this time.
0 commit comments