diff --git a/spacy/tests/test_attrs.py b/spacy/tests/test_attrs.py new file mode 100644 index 000000000..9a3af9d82 --- /dev/null +++ b/spacy/tests/test_attrs.py @@ -0,0 +1,27 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from ..attrs import intify_attrs, ORTH, NORM, LEMMA, IS_ALPHA + +import pytest + + +@pytest.mark.parametrize('text', ["dog"]) +def test_attrs_key(text): + assert intify_attrs({"ORTH": text}) == {ORTH: text} + assert intify_attrs({"NORM": text}) == {NORM: text} + assert intify_attrs({"lemma": text}, strings_map={text: 10}) == {LEMMA: 10} + + +@pytest.mark.parametrize('text', ["dog"]) +def test_attrs_idempotence(text): + int_attrs = intify_attrs({"lemma": text, 'is_alpha': True}, strings_map={text: 10}) + assert intify_attrs(int_attrs) == {LEMMA: 10, IS_ALPHA: True} + + +@pytest.mark.parametrize('text', ["dog"]) +def test_attrs_do_deprecated(text): + int_attrs = intify_attrs({"F": text, 'is_alpha': True}, + strings_map={text: 10}, + _do_deprecated=True) + assert int_attrs == {ORTH: 10, IS_ALPHA: True} diff --git a/spacy/tests/unit/test_attrs.py b/spacy/tests/unit/test_attrs.py deleted file mode 100644 index 9456ef1fa..000000000 --- a/spacy/tests/unit/test_attrs.py +++ /dev/null @@ -1,35 +0,0 @@ -# coding: utf-8 -from __future__ import unicode_literals - -from ...attrs import * - - -def test_key_no_value(): - int_attrs = intify_attrs({"ORTH": "dog"}) - assert int_attrs == {ORTH: "dog"} - - -def test_lower_key(): - int_attrs = intify_attrs({"norm": "dog"}) - assert int_attrs == {NORM: "dog"} - - - -def test_lower_key_value(): - vals = {'dog': 10} - int_attrs = intify_attrs({"lemma": "dog"}, strings_map=vals) - assert int_attrs == {LEMMA: 10} - - -def test_idempotence(): - vals = {'dog': 10} - int_attrs = intify_attrs({"lemma": "dog", 'is_alpha': True}, strings_map=vals) - int_attrs = intify_attrs(int_attrs) - assert int_attrs == {LEMMA: 10, IS_ALPHA: True} - - -def test_do_deprecated(): - vals = {'dog': 10} - int_attrs = intify_attrs({"F": "dog", 'is_alpha': True}, strings_map=vals, - _do_deprecated=True) - assert int_attrs == {ORTH: 10, IS_ALPHA: True}