mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 18:06:29 +03:00
aec130af56
Previous Sputnik integration caused API change: Vocab, Tagger, etc were loaded via a from_package classmethod, that required a sputnik.Package instance. This forced users to first create a sputnik.Sputnik() instance, in order to acquire a Package via sp.pool(). Instead I've created a small file-system shim, util.Package, which allows classes to have a .load() classmethod, that accepts either util.Package objects, or strings. We can later gut the internals of this and make it a proxy for Sputnik if we need more functionality that should live in the Sputnik library. Sputnik is now only used to download and install the data, in spacy.en.download
31 lines
841 B
Python
31 lines
841 B
Python
from spacy.en import English
|
|
|
|
import pytest
|
|
import os
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def EN():
|
|
if os.environ.get('SPACY_DATA'):
|
|
data_path = os.environ.get('SPACY_DATA')
|
|
else:
|
|
data_path = None
|
|
print("Load EN from %s" % data_path)
|
|
return English(data_dir=data_path)
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
parser.addoption("--models", action="store_true",
|
|
help="include tests that require full models")
|
|
parser.addoption("--vectors", action="store_true",
|
|
help="include word vectors tests")
|
|
parser.addoption("--slow", action="store_true",
|
|
help="include slow tests")
|
|
|
|
|
|
|
|
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)
|