From 401045433c3c2ab9957af97914a4f9ebb0949055 Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 23 Apr 2017 21:05:39 +0200 Subject: [PATCH 1/4] Simplify compat.fix_text --- spacy/compat.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spacy/compat.py b/spacy/compat.py index 8458df7b0..1ca8a59fe 100644 --- a/spacy/compat.py +++ b/spacy/compat.py @@ -23,6 +23,8 @@ is_windows = sys.platform.startswith('win') is_linux = sys.platform.startswith('linux') is_osx = sys.platform == 'darwin' +fix_text = ftfy.fix_text + if is_python2: bytes_ = str @@ -39,9 +41,6 @@ elif is_python3: json_dumps = lambda data: ujson.dumps(data, indent=2) -fix_text = lambda text: ftfy.fix_text(text) - - def symlink_to(orig, dest): if is_python2 and is_windows: import subprocess From 83f66947dc06409d6b4260f9256147da518544c3 Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 23 Apr 2017 21:06:36 +0200 Subject: [PATCH 2/4] Rename test_download to test_cli --- spacy/tests/{test_download.py => test_cli.py} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename spacy/tests/{test_download.py => test_cli.py} (79%) diff --git a/spacy/tests/test_download.py b/spacy/tests/test_cli.py similarity index 79% rename from spacy/tests/test_download.py rename to spacy/tests/test_cli.py index 4bbe190df..189a238fc 100644 --- a/spacy/tests/test_download.py +++ b/spacy/tests/test_cli.py @@ -2,17 +2,18 @@ from __future__ import unicode_literals from ..cli.download import download, get_compatibility, get_version, check_error_depr + import pytest @pytest.mark.parametrize('model', ['en_core_web_md']) -def test_download_get_matching_version_succeeds(model): +def test_cli_download_get_matching_version_succeeds(model): comp = { model: ['1.7.0', '0.100.0'] } assert get_version(model, comp) @pytest.mark.parametrize('model', ['en_core_web_md']) -def test_download_get_matching_version_fails(model): +def test_cli_download_get_matching_version_fails(model): diff_model = 'test_' + model comp = { diff_model: ['1.7.0', '0.100.0'] } with pytest.raises(SystemExit): @@ -20,6 +21,6 @@ def test_download_get_matching_version_fails(model): @pytest.mark.parametrize('model', [False, None, '', 'all']) -def test_download_no_model_depr_error(model): +def test_cli_download_no_model_depr_error(model): with pytest.raises(SystemExit): check_error_depr(model) From 012ea594d171041a9ff064783b7c0a392a827d4c Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 23 Apr 2017 21:06:46 +0200 Subject: [PATCH 3/4] Add file for misc tests --- spacy/tests/test_misc.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 spacy/tests/test_misc.py diff --git a/spacy/tests/test_misc.py b/spacy/tests/test_misc.py new file mode 100644 index 000000000..c55e587e7 --- /dev/null +++ b/spacy/tests/test_misc.py @@ -0,0 +1,19 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from ..util import ensure_path + +from pathlib import Path +import pytest + + +@pytest.mark.parametrize('text', ['hello/world', 'hello world']) +def test_util_ensure_path_succeeds(text): + path = ensure_path(text) + assert isinstance(path, Path) + + +@pytest.mark.parametrize('text', [b'hello/world', True, False, None]) +def test_util_ensure_path_fails(text): + path = ensure_path(text) + assert not isinstance(path, Path) From 42305bc519653c1f46bc0acb2ced8196ddc02025 Mon Sep 17 00:00:00 2001 From: ines Date: Sun, 23 Apr 2017 21:21:41 +0200 Subject: [PATCH 4/4] Remove unnecessary test --- spacy/tests/test_misc.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/spacy/tests/test_misc.py b/spacy/tests/test_misc.py index c55e587e7..41c4efb8a 100644 --- a/spacy/tests/test_misc.py +++ b/spacy/tests/test_misc.py @@ -11,9 +11,3 @@ import pytest def test_util_ensure_path_succeeds(text): path = ensure_path(text) assert isinstance(path, Path) - - -@pytest.mark.parametrize('text', [b'hello/world', True, False, None]) -def test_util_ensure_path_fails(text): - path = ensure_path(text) - assert not isinstance(path, Path)