mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
Move attrs tests from unit to root and modernise
This commit is contained in:
parent
3610d27967
commit
01f36ca3ff
27
spacy/tests/test_attrs.py
Normal file
27
spacy/tests/test_attrs.py
Normal file
|
@ -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}
|
|
@ -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}
|
Loading…
Reference in New Issue
Block a user