Add StringStore test for API docs

This commit is contained in:
ines 2017-05-29 01:05:53 +02:00
parent 18b8050b07
commit 804dbb8d25
1 changed files with 19 additions and 0 deletions

View File

@ -6,6 +6,25 @@ from ...strings import StringStore
import pytest
def test_stringstore_from_api_docs(stringstore):
apple_hash = stringstore.add('apple')
assert apple_hash == 8566208034543834098
assert stringstore[apple_hash] == u'apple'
assert u'apple' in stringstore
assert u'cherry' not in stringstore
orange_hash = stringstore.add('orange')
all_strings = [s for s in stringstore]
assert all_strings == [u'apple', u'orange']
banana_hash = stringstore.add('banana')
assert len(stringstore) == 3
assert banana_hash == 2525716904149915114
assert stringstore[banana_hash] == u'banana'
assert stringstore[u'banana'] == banana_hash
@pytest.mark.parametrize('text1,text2,text3', [(b'Hello', b'goodbye', b'hello')])
def test_stringstore_save_bytes(stringstore, text1, text2, text3):
key = stringstore.add(text1)