[Python-checkins] cpython: Issue #29035: Simplify a regex in libregrtest
victor.stinner
python-checkins at python.org
Mon Jan 2 19:42:22 EST 2017
https://hg.python.org/cpython/rev/a9fe5bee892b
changeset: 105968:a9fe5bee892b
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Jan 03 01:38:58 2017 +0100
summary:
Issue #29035: Simplify a regex in libregrtest
regrtest: simplify the regex used to match test names for the --fromfile
command line option.
files:
Lib/test/libregrtest/main.py | 7 ++-----
Lib/test/test_regrtest.py | 8 ++++++++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -179,17 +179,14 @@
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)
diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
--- a/Lib/test/test_regrtest.py
+++ b/Lib/test/test_regrtest.py
@@ -676,6 +676,14 @@
output = self.run_tests('--fromfile', filename)
self.check_executed_tests(output, tests)
+ # test format 'Lib/test/test_opcodes.py'
+ with open(filename, "w") as fp:
+ for name in tests:
+ print('Lib/test/%s.py' % name, file=fp)
+
+ output = self.run_tests('--fromfile', filename)
+ self.check_executed_tests(output, tests)
+
def test_interrupted(self):
code = TEST_INTERRUPTED
test = self.create_test('sigint', code=code)
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list