mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
Add --test-files option to py.test
At this point, py.test should be equivalent to test/run.py
This commit is contained in:
@@ -8,18 +8,40 @@ def pytest_addoption(parser):
|
|||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--base-dir", default=default_base_dir,
|
"--base-dir", default=default_base_dir,
|
||||||
help="Directory in which integration test case files locate.")
|
help="Directory in which integration test case files locate.")
|
||||||
|
parser.addoption(
|
||||||
|
"--test-files", "-T", default=[], action='append',
|
||||||
|
help=(
|
||||||
|
"Specify test files using FILE_NAME[:LINE[,LINE[,...]]]. "
|
||||||
|
"For example: -T generators.py:10,13,19. "
|
||||||
|
"Note that you can use -m to specify the test case by id."))
|
||||||
parser.addoption(
|
parser.addoption(
|
||||||
"--thirdparty",
|
"--thirdparty",
|
||||||
help="Include integration tests that requires third party modules.")
|
help="Include integration tests that requires third party modules.")
|
||||||
|
|
||||||
|
|
||||||
|
def parse_test_files_option(opt):
|
||||||
|
"""
|
||||||
|
Parse option passed to --test-files into a key-value pair.
|
||||||
|
|
||||||
|
>>> parse_test_files_option('generators.py:10,13,19')
|
||||||
|
('generators.py', [10, 13, 19])
|
||||||
|
"""
|
||||||
|
opt = str(opt)
|
||||||
|
if ':' in opt:
|
||||||
|
(f_name, rest) = opt.split(':', 1)
|
||||||
|
return (f_name, list(map(int, rest.split(','))))
|
||||||
|
else:
|
||||||
|
return (opt, [])
|
||||||
|
|
||||||
|
|
||||||
def pytest_generate_tests(metafunc):
|
def pytest_generate_tests(metafunc):
|
||||||
"""
|
"""
|
||||||
:type metafunc: _pytest.python.Metafunc
|
:type metafunc: _pytest.python.Metafunc
|
||||||
"""
|
"""
|
||||||
if 'case' in metafunc.fixturenames:
|
if 'case' in metafunc.fixturenames:
|
||||||
base_dir = metafunc.config.option.base_dir
|
base_dir = metafunc.config.option.base_dir
|
||||||
test_files = {}
|
test_files = dict(map(parse_test_files_option,
|
||||||
|
metafunc.config.option.test_files))
|
||||||
thirdparty = metafunc.config.option.thirdparty
|
thirdparty = metafunc.config.option.thirdparty
|
||||||
metafunc.parametrize(
|
metafunc.parametrize(
|
||||||
'case',
|
'case',
|
||||||
|
|||||||
Reference in New Issue
Block a user