avoid the tests interacting with eachother through the global Underscore variable

This commit is contained in:
svlandeg 2020-02-12 13:21:31 +01:00
parent 7939c63886
commit 6e717c62ed
2 changed files with 13 additions and 0 deletions

View File

@ -3,11 +3,17 @@ from __future__ import unicode_literals
from spacy.lang.en import English
from spacy.pipeline import EntityRuler
from spacy.tokens.underscore import Underscore
def test_issue4849():
nlp = English()
# reset the Underscore object because test_underscore has a lambda function that can't be pickled
Underscore.doc_extensions = {}
Underscore.span_extensions = {}
Underscore.token_extensions = {}
ruler = EntityRuler(
nlp, patterns=[
{"label": "PERSON", "pattern": 'joe biden', "id": 'joe-biden'},

View File

@ -4,6 +4,7 @@ from __future__ import unicode_literals
import spacy
from spacy.lang.en import English
from spacy.tokens import Span, Doc
from spacy.tokens.underscore import Underscore
class CustomPipe:
@ -31,6 +32,12 @@ class CustomPipe:
def test_issue4903():
# ensures that this runs correctly and doesn't hang or crash on Windows / macOS
# reset the Underscore object because test_underscore has a lambda function that can't be pickled
Underscore.doc_extensions = {}
Underscore.span_extensions = {}
Underscore.token_extensions = {}
nlp = English()
custom_component = CustomPipe()
nlp.add_pipe(nlp.create_pipe("sentencizer"))