Skip to content

Commit

Permalink
Allow a regular expression for filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephan-hof committed Dec 28, 2016
1 parent 262a9ea commit f0a8c0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/zope/testrunner/options.py
Expand Up @@ -250,6 +250,9 @@
dest='ignore_new_threads',
help="""\
If a thread with this name is left behind, don't report this at the end.
This is a case-sensitive regular expression, used in match mode.
This option can be used multiple times. If a thread name matches any of them,
it will be ignored.
""")


Expand Down
8 changes: 4 additions & 4 deletions src/zope/testrunner/runner.py
Expand Up @@ -851,10 +851,10 @@ def stopTest(self, test):
# Did the test leave any new threads behind?
new_threads = []
for t in threading.enumerate():
if t.isAlive():
if t not in self._threads:
if t.name not in self.options.ignore_new_threads:
new_threads.append(t)
if t.isAlive() and t not in self._threads:
if not any([re.match(p, t.name)
for p in self.options.ignore_new_threads]):
new_threads.append(t)

if new_threads:
self.options.output.test_threads(test, new_threads)
Expand Down

0 comments on commit f0a8c0c

Please sign in to comment.