From f0a8c0ced8dcd785eace94255b4877264ec61bb2 Mon Sep 17 00:00:00 2001 From: stephan-hof Date: Fri, 23 Dec 2016 08:21:36 +0100 Subject: [PATCH] Allow a regular expression for filtering. --- src/zope/testrunner/options.py | 3 +++ src/zope/testrunner/runner.py | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/zope/testrunner/options.py b/src/zope/testrunner/options.py index 59536c8..2281faa 100644 --- a/src/zope/testrunner/options.py +++ b/src/zope/testrunner/options.py @@ -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. """) diff --git a/src/zope/testrunner/runner.py b/src/zope/testrunner/runner.py index 0251932..e82c7a7 100644 --- a/src/zope/testrunner/runner.py +++ b/src/zope/testrunner/runner.py @@ -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)