mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-25 17:36:30 +03:00
* Add tests for string intern
This commit is contained in:
parent
7baef5b7ff
commit
168b2b8cb2
35
tests/test_intern.py
Normal file
35
tests/test_intern.py
Normal file
|
@ -0,0 +1,35 @@
|
|||
# -*- coding: utf8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from spacy.utf8string import StringStore
|
||||
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def sstore():
|
||||
return StringStore()
|
||||
|
||||
def test_save_bytes(sstore):
|
||||
Hello_i = sstore[b'Hello']
|
||||
assert Hello_i == 1
|
||||
assert sstore[b'Hello'] == 1
|
||||
assert sstore[b'goodbye'] != Hello_i
|
||||
assert sstore[b'hello'] != Hello_i
|
||||
assert Hello_i == 1
|
||||
|
||||
|
||||
def test_save_unicode(sstore):
|
||||
with pytest.raises(TypeError):
|
||||
A_i = sstore['A']
|
||||
|
||||
|
||||
def test_zero_id(sstore):
|
||||
with pytest.raises(IndexError):
|
||||
sstore[0]
|
||||
|
||||
def test_retrieve_id(sstore):
|
||||
A_i = sstore[b'A']
|
||||
assert sstore.size == 1
|
||||
assert sstore[1] == b'A'
|
||||
with pytest.raises(IndexError):
|
||||
sstore[2]
|
Loading…
Reference in New Issue
Block a user