From 6e3937efc5d30720ee05a51b379920b5372bb16d Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 29 May 2017 22:10:16 +0200 Subject: [PATCH] Check for arguments of model markers to specify models to test Lets user set --models --en for only English models --- spacy/tests/conftest.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spacy/tests/conftest.py b/spacy/tests/conftest.py index 6b577be62..445331fda 100644 --- a/spacy/tests/conftest.py +++ b/spacy/tests/conftest.py @@ -129,8 +129,18 @@ def pytest_addoption(parser): parser.addoption("--slow", action="store_true", help="include slow tests") + for lang in _languages + ['all']: + parser.addoption("--%s" % lang, action="store_true", help="Use %s models" % lang) + def pytest_runtest_setup(item): for opt in ['models', 'vectors', 'slow']: if opt in item.keywords and not item.config.getoption("--%s" % opt): pytest.skip("need --%s option to run" % opt) + + # Check if test is marked with models and has arguments set, i.e. specific + # language. If so, skip test if flag not set. + if item.get_marker('models'): + for arg in item.get_marker('models').args: + if not item.config.getoption("--%s" % arg) and not item.config.getoption("--all"): + pytest.skip()