summaryrefslogtreecommitdiffstats
path: root/devscripts/run_tests.py
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xdevscripts/run_tests.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/devscripts/run_tests.py b/devscripts/run_tests.py
index 6d638a9..c605aa6 100755
--- a/devscripts/run_tests.py
+++ b/devscripts/run_tests.py
@@ -4,6 +4,7 @@ import argparse
import functools
import os
import re
+import shlex
import subprocess
import sys
from pathlib import Path
@@ -18,6 +19,8 @@ def parse_args():
'test', help='a extractor tests, or one of "core" or "download"', nargs='*')
parser.add_argument(
'-k', help='run a test matching EXPRESSION. Same as "pytest -k"', metavar='EXPRESSION')
+ parser.add_argument(
+ '--pytest-args', help='arguments to passthrough to pytest')
return parser.parse_args()
@@ -26,15 +29,16 @@ def run_tests(*tests, pattern=None, ci=False):
run_download = 'download' in tests
tests = list(map(fix_test_name, tests))
- arguments = ['pytest', '-Werror', '--tb=short']
+ pytest_args = args.pytest_args or os.getenv('HATCH_TEST_ARGS', '')
+ arguments = ['pytest', '-Werror', '--tb=short', *shlex.split(pytest_args)]
if ci:
arguments.append('--color=yes')
+ if pattern:
+ arguments.extend(['-k', pattern])
if run_core:
arguments.extend(['-m', 'not download'])
elif run_download:
arguments.extend(['-m', 'download'])
- elif pattern:
- arguments.extend(['-k', pattern])
else:
arguments.extend(
f'test/test_download.py::TestDownload::test_{test}' for test in tests)
@@ -46,13 +50,13 @@ def run_tests(*tests, pattern=None, ci=False):
pass
arguments = [sys.executable, '-Werror', '-m', 'unittest']
+ if pattern:
+ arguments.extend(['-k', pattern])
if run_core:
print('"pytest" needs to be installed to run core tests', file=sys.stderr, flush=True)
return 1
elif run_download:
arguments.append('test.test_download')
- elif pattern:
- arguments.extend(['-k', pattern])
else:
arguments.extend(
f'test.test_download.TestDownload.test_{test}' for test in tests)