From 6303ce3d0ee3f78deb4fd2bbfcc3ed6d8609d22b Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 24 Jul 2018 20:09:06 +0200 Subject: [PATCH] Try to fix memory error by moving fr_tokenizer to module scope --- spacy/tests/conftest.py | 5 ----- spacy/tests/lang/fr/test_exceptions.py | 7 ++++++- spacy/tests/lang/fr/test_text.py | 8 ++++++++ spacy/tests/regression/test_issue852.py | 7 +++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/spacy/tests/conftest.py b/spacy/tests/conftest.py index 0f4340fe2..4bb535a74 100644 --- a/spacy/tests/conftest.py +++ b/spacy/tests/conftest.py @@ -92,11 +92,6 @@ def de_tokenizer(): return util.get_lang_class('de').Defaults.create_tokenizer() -@pytest.fixture(scope='session') -def fr_tokenizer(): - return util.get_lang_class('fr').Defaults.create_tokenizer() - - @pytest.fixture(scope='session') def hu_tokenizer(): return util.get_lang_class('hu').Defaults.create_tokenizer() diff --git a/spacy/tests/lang/fr/test_exceptions.py b/spacy/tests/lang/fr/test_exceptions.py index b3ae78e20..00744eb14 100644 --- a/spacy/tests/lang/fr/test_exceptions.py +++ b/spacy/tests/lang/fr/test_exceptions.py @@ -3,6 +3,11 @@ from __future__ import unicode_literals import pytest +from .... import util + +@pytest.fixture(scope='module') +def fr_tokenizer(): + return util.get_lang_class('fr').Defaults.create_tokenizer() @pytest.mark.parametrize('text', ["aujourd'hui", "Aujourd'hui", "prud'hommes", @@ -62,4 +67,4 @@ def test_tokenizer_handles_title_2(fr_tokenizer): tokens = fr_tokenizer(text) assert len(tokens) == 7 assert tokens[0].text == "Qu'" - assert tokens[0].lemma_ == "que" \ No newline at end of file + assert tokens[0].lemma_ == "que" diff --git a/spacy/tests/lang/fr/test_text.py b/spacy/tests/lang/fr/test_text.py index 94a12e3b6..5c56d4053 100644 --- a/spacy/tests/lang/fr/test_text.py +++ b/spacy/tests/lang/fr/test_text.py @@ -1,5 +1,13 @@ # coding: utf8 from __future__ import unicode_literals +import pytest + +from .... import util + +@pytest.fixture(scope='module') +def fr_tokenizer(): + return util.get_lang_class('fr').Defaults.create_tokenizer() + def test_tokenizer_handles_long_text(fr_tokenizer): diff --git a/spacy/tests/regression/test_issue852.py b/spacy/tests/regression/test_issue852.py index 2bfbe99bb..3888ed353 100644 --- a/spacy/tests/regression/test_issue852.py +++ b/spacy/tests/regression/test_issue852.py @@ -3,6 +3,13 @@ from __future__ import unicode_literals import pytest +from ... import util + +@pytest.fixture(scope='module') +def fr_tokenizer(): + return util.get_lang_class('fr').Defaults.create_tokenizer() + + @pytest.mark.parametrize('text', ["au-delàs", "pair-programmâmes", "terra-formées", "σ-compacts"])