From 049197e0ae66e61737f8d4954f4512b5aa971703 Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Sat, 15 Oct 2016 14:14:04 +0200 Subject: [PATCH] Update tests, somewhat messily. --- spacy/tests/tagger/test_lemmatizer.py | 38 ++++++++++++++++++++------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/spacy/tests/tagger/test_lemmatizer.py b/spacy/tests/tagger/test_lemmatizer.py index fb3306216..e90d62c84 100644 --- a/spacy/tests/tagger/test_lemmatizer.py +++ b/spacy/tests/tagger/test_lemmatizer.py @@ -21,25 +21,31 @@ def path(): @pytest.fixture def lemmatizer(path): - print('Path', repr(path)) - return Lemmatizer.load(path) + if path is not None: + return Lemmatizer.load(path) + else: + return None def test_read_index(path): - with (path / 'wordnet' / 'index.noun').open() as file_: - index = read_index(file_) - assert 'man' in index - assert 'plantes' not in index - assert 'plant' in index + if path is not None: + with (path / 'wordnet' / 'index.noun').open() as file_: + index = read_index(file_) + assert 'man' in index + assert 'plantes' not in index + assert 'plant' in index def test_read_exc(path): - with (path / 'wordnet' / 'verb.exc').open() as file_: - exc = read_exc(file_) - assert exc['was'] == ('be',) + if path is not None: + with (path / 'wordnet' / 'verb.exc').open() as file_: + exc = read_exc(file_) + assert exc['was'] == ('be',) def test_noun_lemmas(lemmatizer): + if lemmatizer is None: + return None do = lemmatizer.noun assert do('aardwolves') == set(['aardwolf']) @@ -50,23 +56,35 @@ def test_noun_lemmas(lemmatizer): def test_base_form_dive(lemmatizer): + if lemmatizer is None: + return None + do = lemmatizer.noun assert do('dive', number='sing') == set(['dive']) assert do('dive', number='plur') == set(['diva']) def test_base_form_saw(lemmatizer): + if lemmatizer is None: + return None + do = lemmatizer.verb assert do('saw', verbform='past') == set(['see']) def test_smart_quotes(lemmatizer): + if lemmatizer is None: + return None + do = lemmatizer.punct assert do('“') == set(['"']) assert do('“') == set(['"']) def test_pickle_lemmatizer(lemmatizer): + if lemmatizer is None: + return None + file_ = io.BytesIO() pickle.dump(lemmatizer, file_)