2014-10-23 13:47:06 +04:00
|
|
|
# -*- coding: utf8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2014-12-21 12:44:21 +03:00
|
|
|
from spacy.strings import StringStore
|
2014-10-23 13:47:06 +04:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
2015-04-19 22:39:18 +03:00
|
|
|
|
2014-10-23 13:47:06 +04:00
|
|
|
@pytest.fixture
|
|
|
|
def sstore():
|
|
|
|
return StringStore()
|
|
|
|
|
2015-04-19 22:39:18 +03:00
|
|
|
|
2014-10-23 13:47:06 +04:00
|
|
|
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):
|
2014-12-02 17:33:20 +03:00
|
|
|
Hello_i = sstore[u'Hello']
|
|
|
|
assert Hello_i == 1
|
|
|
|
assert sstore[u'Hello'] == 1
|
|
|
|
assert sstore[u'goodbye'] != Hello_i
|
|
|
|
assert sstore[u'hello'] != Hello_i
|
|
|
|
assert Hello_i == 1
|
2014-10-23 13:47:06 +04:00
|
|
|
|
|
|
|
|
|
|
|
def test_retrieve_id(sstore):
|
|
|
|
A_i = sstore[b'A']
|
|
|
|
assert sstore.size == 1
|
2015-01-25 11:04:23 +03:00
|
|
|
assert sstore[1] == 'A'
|
2014-10-23 13:47:06 +04:00
|
|
|
with pytest.raises(IndexError):
|
|
|
|
sstore[2]
|