mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-24 00:04:15 +03:00
Merge pull request #9423 from explosion/tests/issue-marker
This commit is contained in:
commit
c48564688f
|
@ -122,7 +122,8 @@ exclude =
|
||||||
|
|
||||||
[tool:pytest]
|
[tool:pytest]
|
||||||
markers =
|
markers =
|
||||||
slow
|
slow: mark a test as slow
|
||||||
|
issue: reference specific issue
|
||||||
|
|
||||||
[mypy]
|
[mypy]
|
||||||
ignore_missing_imports = True
|
ignore_missing_imports = True
|
||||||
|
|
|
@ -4,6 +4,7 @@ from spacy.util import get_lang_class
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--slow", action="store_true", help="include slow tests")
|
parser.addoption("--slow", action="store_true", help="include slow tests")
|
||||||
|
parser.addoption("--issue", action="store", help="test specific issues")
|
||||||
|
|
||||||
|
|
||||||
def pytest_runtest_setup(item):
|
def pytest_runtest_setup(item):
|
||||||
|
@ -16,10 +17,24 @@ def pytest_runtest_setup(item):
|
||||||
# options weren't given.
|
# options weren't given.
|
||||||
return item.config.getoption(f"--{opt}", False)
|
return item.config.getoption(f"--{opt}", False)
|
||||||
|
|
||||||
|
# Integration of boolean flags
|
||||||
for opt in ["slow"]:
|
for opt in ["slow"]:
|
||||||
if opt in item.keywords and not getopt(opt):
|
if opt in item.keywords and not getopt(opt):
|
||||||
pytest.skip(f"need --{opt} option to run")
|
pytest.skip(f"need --{opt} option to run")
|
||||||
|
|
||||||
|
# Special integration to mark tests with issue numbers
|
||||||
|
issues = getopt("issue")
|
||||||
|
if isinstance(issues, str):
|
||||||
|
if "issue" in item.keywords:
|
||||||
|
# Convert issues provided on the CLI to list of ints
|
||||||
|
issue_nos = [int(issue.strip()) for issue in issues.split(",")]
|
||||||
|
# Get all issues specified by decorators and check if they're provided
|
||||||
|
issue_refs = [mark.args[0] for mark in item.iter_markers(name="issue")]
|
||||||
|
if not any([ref in issue_nos for ref in issue_refs]):
|
||||||
|
pytest.skip(f"not referencing specified issues: {issue_nos}")
|
||||||
|
else:
|
||||||
|
pytest.skip("not referencing any issues")
|
||||||
|
|
||||||
|
|
||||||
# Fixtures for language tokenizers (languages sorted alphabetically)
|
# Fixtures for language tokenizers (languages sorted alphabetically)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import pytest
|
||||||
from spacy.lang.en import English
|
from spacy.lang.en import English
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.issue(8168)
|
||||||
def test_issue8168():
|
def test_issue8168():
|
||||||
nlp = English()
|
nlp = English()
|
||||||
ruler = nlp.add_pipe("entity_ruler")
|
ruler = nlp.add_pipe("entity_ruler")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user