Remove references to Python 2 / is_python2

This commit is contained in:
Ines Montani 2020-06-20 16:11:13 +02:00
parent 0cdb631e6c
commit 296b5d633b
3 changed files with 7 additions and 16 deletions

View File

@ -8,7 +8,6 @@ from spacy.kb import KnowledgeBase, Writer
from spacy.vectors import Vectors
from spacy.language import Language
from spacy.pipeline import Pipe
from spacy.compat import is_python2
from ..util import make_tempdir
@ -97,14 +96,12 @@ def write_obj_and_catch_warnings(obj):
return list(filter(lambda x: isinstance(x, ResourceWarning), warnings_list))
@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x")
@pytest.mark.parametrize("obj", objects_to_test[0], ids=objects_to_test[1])
def test_to_disk_resource_warning(obj):
warnings_list = write_obj_and_catch_warnings(obj)
assert len(warnings_list) == 0
@pytest.mark.skipif(is_python2, reason="ResourceWarning needs Python 3.x")
def test_writer_with_path_py35():
writer = None
with make_tempdir() as d:
@ -135,13 +132,11 @@ def test_save_and_load_knowledge_base():
pytest.fail(str(e))
if not is_python2:
class TestToDiskResourceWarningUnittest(TestCase):
def test_resource_warning(self):
scenarios = zip(*objects_to_test)
class TestToDiskResourceWarningUnittest(TestCase):
def test_resource_warning(self):
scenarios = zip(*objects_to_test)
for scenario in scenarios:
with self.subTest(msg=scenario[1]):
warnings_list = write_obj_and_catch_warnings(scenario[0])
self.assertEqual(len(warnings_list), 0)
for scenario in scenarios:
with self.subTest(msg=scenario[1]):
warnings_list = write_obj_and_catch_warnings(scenario[0])
self.assertEqual(len(warnings_list), 0)

View File

@ -2,7 +2,6 @@ import pytest
import pickle
from spacy.vocab import Vocab
from spacy.strings import StringStore
from spacy.compat import is_python2
from ..util import make_tempdir
@ -135,7 +134,6 @@ def test_serialize_stringstore_roundtrip_disk(strings1, strings2):
assert list(sstore1_d) != list(sstore2_d)
@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating")
@pytest.mark.parametrize("strings,lex_attr", test_strings_attrs)
def test_pickle_vocab(strings, lex_attr):
vocab = Vocab(strings=strings)

View File

@ -6,7 +6,6 @@ from spacy.vectors import Vectors
from spacy.tokenizer import Tokenizer
from spacy.strings import hash_string
from spacy.tokens import Doc
from spacy.compat import is_python2
from ..util import add_vecs_to_vocab, get_cosine, make_tempdir
@ -336,7 +335,6 @@ def test_vocab_prune_vectors():
assert_allclose(similarity, get_cosine(data[0], data[2]), atol=1e-4, rtol=1e-3)
@pytest.mark.skipif(is_python2, reason="Dict order? Not sure if worth investigating")
def test_vectors_serialize():
data = numpy.asarray([[4, 2, 2, 2], [4, 2, 2, 2], [1, 1, 1, 1]], dtype="f")
v = Vectors(data=data, keys=["A", "B", "C"])