mirror of https://github.com/explosion/spaCy.git
* Fix tempfile in test
This commit is contained in:
parent
f11030aadc
commit
725344d349
|
@ -5,6 +5,7 @@ import pickle
|
||||||
from spacy.strings import StringStore
|
from spacy.strings import StringStore
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import io
|
import io
|
||||||
|
|
||||||
|
@ -95,10 +96,9 @@ def test_pickle_string_store(sstore):
|
||||||
|
|
||||||
def test_dump_load(sstore):
|
def test_dump_load(sstore):
|
||||||
id_ = sstore[u'qqqqq']
|
id_ = sstore[u'qqqqq']
|
||||||
loc = '/tmp/sstore.json'
|
with tempfile.TemporaryFile() as file_:
|
||||||
with io.open(loc, 'w', encoding='utf8') as file_:
|
|
||||||
sstore.dump(file_)
|
sstore.dump(file_)
|
||||||
|
file_.seek(0)
|
||||||
new_store = StringStore()
|
new_store = StringStore()
|
||||||
with io.open(loc, 'r', encoding='utf8') as file_:
|
|
||||||
new_store.load(file_)
|
new_store.load(file_)
|
||||||
assert new_store[id_] == u'qqqqq'
|
assert new_store[id_] == u'qqqqq'
|
||||||
|
|
Loading…
Reference in New Issue