Add load_test_model function with importorskip()
Loads model only if it can be imported, i.e. if it's installed as a
package.
@@ -4,9 +4,20 @@ from __future__ import unicode_literals
from ..tokens import Doc
from ..attrs import ORTH, POS, HEAD, DEP
+import pytest
import numpy
+MODELS = {}
+
+
+def load_test_model(model):
+ if model not in MODELS:
+ module = pytest.importorskip(model)
+ MODELS[model] = module.load()
+ return MODELS[model]
+
+
def get_doc(vocab, words=[], pos=None, heads=None, deps=None, tags=None, ents=None):
"""Create Doc object from given vocab, words and annotations."""
pos = pos or [''] * len(words)
