Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 1414bc8

Browse files
author
Matthias Koeppe
committed
src/bin/sage-runtests: Do not run pytest on individual Python files unless they match the pytest file pattern
1 parent 43474c9 commit 1414bc8

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/bin/sage-runtests

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,15 @@ if __name__ == "__main__":
154154
pytest_options = ["--import-mode", "importlib"]
155155
if args.verbose:
156156
pytest_options.append("-v")
157-
exit_code_pytest = pytest.main(pytest_options + args.filenames)
158-
if exit_code_pytest == 5:
159-
# Exit code 5 means there were no test files, pass in this case
160-
exit_code_pytest = 0
157+
# 31914: Do not run pytest on individual Python files unless
158+
# they match the pytest file pattern
159+
filenames = [f for f in args.filenames
160+
if f.endswith("_test.py") or not f.endswith(".py")]
161+
if filenames or not args.filenames:
162+
exit_code_pytest = pytest.main(pytest_options + filenames)
163+
if exit_code_pytest == 5:
164+
# Exit code 5 means there were no test files, pass in this case
165+
exit_code_pytest = 0
161166

162167
except ModuleNotFoundError:
163168
print("Pytest is not installed, skip checking tests that rely on it.")

0 commit comments

Comments
 (0)