summaryrefslogtreecommitdiffstats
path: root/Lib/test/libregrtest
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-01-03 00:38:58 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2017-01-03 00:38:58 (GMT)
commite8cfec5abc8a9401543aa4af5b20ae7afec89198 (patch)
treec773fe9df0c7f2f6dc013f392199e34c448f9408 /Lib/test/libregrtest
parentc9c760d6ecacfd08f0ec55ebb7ac54757372d3c5 (diff)
downloadcpython-e8cfec5abc8a9401543aa4af5b20ae7afec89198.zip
cpython-e8cfec5abc8a9401543aa4af5b20ae7afec89198.tar.gz
cpython-e8cfec5abc8a9401543aa4af5b20ae7afec89198.tar.bz2
Issue #29035: Simplify a regex in libregrtest
regrtest: simplify the regex used to match test names for the --fromfile command line option.
Diffstat (limited to 'Lib/test/libregrtest')
-rw-r--r--Lib/test/libregrtest/main.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index e113ed6..61a9876 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -179,17 +179,14 @@ class Regrtest:
self.tests = []
# regex to match 'test_builtin' in line:
# '0:00:00 [ 4/400] test_builtin -- test_dict took 1 sec'
- regex = (r'(?:[0-9]+:[0-9]+:[0-9]+ *)?'
- r'(?:\[[0-9/ ]+\] *)?'
- r'(test_[a-zA-Z0-9_]+)\b(?:\.py)?')
- regex = re.compile(regex)
+ regex = re.compile(r'\btest_[a-zA-Z0-9_]+\b')
with open(os.path.join(support.SAVEDCWD, self.ns.fromfile)) as fp:
for line in fp:
line = line.split('#', 1)[0]
line = line.strip()
match = regex.search(line)
if match is not None:
- self.tests.append(match.group(1))
+ self.tests.append(match.group())
removepy(self.tests)