Commit 75256255 authored by Jérome Perrin's avatar Jérome Perrin

use re.search to filter tests in --run

re.match only find matches where the pattern appears at the beginning of
the string, whereas re.search matches if the pattern appears anywhere in
the string. This is behavior is consistent with pytest, go test and ERP5's
runUnitTest
parent 1e6a1cc6
Pipeline #12519 passed with stage
in 0 seconds
......@@ -355,7 +355,7 @@ class LocalTestResult:
self.next += 1
# --run
if self.run is not None and not re.match(self.run, t.name):
if self.run is not None and not re.search(self.run, t.name):
continue
test_result_line = LocalTestResultLine()
......
......@@ -93,7 +93,20 @@ TestCase('TEST2', ['echo', 'TEST2'])
""",
argv=["nxdtest", "--run", "TEST1"],
)
captured = capsys.readouterr()
assert "TEST1" in captured.out
assert "TEST2" not in captured.out
# --run uses search
run_nxdtest(
"""\
TestCase('TEST1', ['echo', 'TEST1'])
TestCase('TEST2', ['echo', 'TEST2'])
TestCase('TEST10', ['echo', 'TEST10'])
""",
argv=["nxdtest", "--run", "ST1"],
)
captured = capsys.readouterr()
assert "TEST1" in captured.out
assert "TEST10" in captured.out
assert "TEST2" not in captured.out
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment