diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2021-10-29 09:33:54 -0700 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2021-10-29 09:52:53 -0700 |
commit | 68ae5aed1d0591ba510bcb2b6f7e548fd2476bbe (patch) | |
tree | 225ed77b0a55558f59aacad353e3feed46a13c04 /tests | |
parent | be8d85ee80e2624c2d89bbb72bffe4a9579f0276 (diff) | |
download | natsort-68ae5aed1d0591ba510bcb2b6f7e548fd2476bbe.tar.gz |
Fix other bugs introduced in the shuffle
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_final_data_transform_factory.py | 2 | ||||
-rw-r--r-- | tests/test_input_string_transform_factory.py | 2 | ||||
-rw-r--r-- | tests/test_main.py | 2 | ||||
-rw-r--r-- | tests/test_natsort_key.py | 14 | ||||
-rw-r--r-- | tests/test_natsort_keygen.py | 2 | ||||
-rw-r--r-- | tests/test_natsorted.py | 2 | ||||
-rw-r--r-- | tests/test_natsorted_convenience.py | 2 | ||||
-rw-r--r-- | tests/test_parse_string_function.py | 2 | ||||
-rw-r--r-- | tests/test_string_component_transform_factory.py | 2 | ||||
-rw-r--r-- | tests/test_utils.py | 12 |
10 files changed, 22 insertions, 20 deletions
diff --git a/tests/test_final_data_transform_factory.py b/tests/test_final_data_transform_factory.py index a34ac22..36607b6 100644 --- a/tests/test_final_data_transform_factory.py +++ b/tests/test_final_data_transform_factory.py @@ -5,7 +5,7 @@ from typing import Callable, Union import pytest from hypothesis import example, given from hypothesis.strategies import floats, integers, text -from natsort.ns_enum import NS_DUMB, NSType, ns +from natsort.ns_enum import NSType, NS_DUMB, ns from natsort.utils import final_data_transform_factory diff --git a/tests/test_input_string_transform_factory.py b/tests/test_input_string_transform_factory.py index d89dd77..6a08318 100644 --- a/tests/test_input_string_transform_factory.py +++ b/tests/test_input_string_transform_factory.py @@ -5,7 +5,7 @@ from typing import Callable import pytest from hypothesis import example, given from hypothesis.strategies import integers, text -from natsort.ns_enum import NS_DUMB, NSType, ns +from natsort.ns_enum import NSType, NS_DUMB, ns from natsort.utils import input_string_transform_factory diff --git a/tests/test_main.py b/tests/test_main.py index 0ed9d25..2f784a1 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -31,7 +31,7 @@ def test_main_passes_default_arguments_with_no_command_line_options( assert not args.paths assert args.filter is None assert args.reverse_filter is None - assert args.exclude is None + assert args.exclude == [] assert not args.reverse assert args.number_type == "int" assert not args.signed diff --git a/tests/test_natsort_key.py b/tests/test_natsort_key.py index b9a63ec..cdfdc67 100644 --- a/tests/test_natsort_key.py +++ b/tests/test_natsort_key.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """These test the utils.py functions.""" -from typing import Any, List, NoReturn, Tuple, Union +from typing import Any, List, NoReturn, Tuple, Union, cast from hypothesis import given from hypothesis.strategies import binary, floats, integers, lists, text @@ -20,24 +20,26 @@ def fail(_: Any) -> NoReturn: @given(floats(allow_nan=False) | integers()) def test_natsort_key_with_numeric_input_takes_number_path(x: Union[float, int]) -> None: - assert natsort_key(x, None, str_func, fail, lambda y: ("", y)) is x + assert natsort_key(x, None, str_func, fail, lambda y: ("", y))[1] is x @given(binary().filter(bool)) def test_natsort_key_with_bytes_input_takes_bytes_path(x: bytes) -> None: - assert natsort_key(x, None, str_func, lambda y: (y,), fail) is x + assert natsort_key(x, None, str_func, lambda y: (y,), fail)[0] is x @given(text()) def test_natsort_key_with_text_input_takes_string_path(x: str) -> None: - assert natsort_key(x, None, str_func, fail, fail) is x + assert natsort_key(x, None, str_func, fail, fail)[0] is x @given(lists(elements=text(), min_size=1, max_size=10)) def test_natsort_key_with_nested_input_takes_nested_path(x: List[str]) -> None: - assert natsort_key(x, None, str_func, fail, fail) == tuple(x) + assert natsort_key(x, None, str_func, fail, fail) == tuple((y,) for y in x) @given(text()) def test_natsort_key_with_key_argument_applies_key_before_processing(x: str) -> None: - assert natsort_key(x, len, str_func, fail, lambda y: ("", y)) == len(x) + assert natsort_key(x, len, str_func, fail, lambda y: ("", cast(int, y)))[1] == len( + x + ) diff --git a/tests/test_natsort_keygen.py b/tests/test_natsort_keygen.py index 251b349..d4da2e3 100644 --- a/tests/test_natsort_keygen.py +++ b/tests/test_natsort_keygen.py @@ -109,7 +109,7 @@ def test_natsort_keygen_handles_bytes_input( @pytest.mark.parametrize( - "alg, expected_in, is_dumb", + "alg, expected, is_dumb", [ ( ns.LOCALE, diff --git a/tests/test_natsorted.py b/tests/test_natsorted.py index 2945d00..d043ab4 100644 --- a/tests/test_natsorted.py +++ b/tests/test_natsorted.py @@ -6,10 +6,10 @@ See the README or the natsort homepage for more details. from operator import itemgetter from typing import List, Tuple, Union -from natsort.ns_enum import NSType import pytest from natsort import as_utf8, natsorted, ns +from natsort.ns_enum import NSType from pytest import raises diff --git a/tests/test_natsorted_convenience.py b/tests/test_natsorted_convenience.py index 599c4ba..0b2cd75 100644 --- a/tests/test_natsorted_convenience.py +++ b/tests/test_natsorted_convenience.py @@ -38,7 +38,7 @@ def fruit_list() -> List[str]: return ["Apple", "corn", "Corn", "Banana", "apple", "banana"] -def test_decoder_returns_function_that_can_decode_bytes_but_return_non_bytes_as_is() -> None: +def test_decoder_returns_function_that_decodes_bytes_but_returns_other_as_is() -> None: func = decoder("latin1") str_obj = "bytes" int_obj = 14 diff --git a/tests/test_parse_string_function.py b/tests/test_parse_string_function.py index dcd10ce..653a065 100644 --- a/tests/test_parse_string_function.py +++ b/tests/test_parse_string_function.py @@ -8,7 +8,7 @@ import pytest from hypothesis import given from hypothesis.strategies import floats, integers, lists, text from natsort.compat.fastnumbers import fast_float -from natsort.ns_enum import NS_DUMB, NSType, ns +from natsort.ns_enum import NSType, NS_DUMB, ns from natsort.utils import ( FinalTransform, NumericalRegularExpressions as NumRegex, diff --git a/tests/test_string_component_transform_factory.py b/tests/test_string_component_transform_factory.py index fcbfcb7..99df7ea 100644 --- a/tests/test_string_component_transform_factory.py +++ b/tests/test_string_component_transform_factory.py @@ -9,7 +9,7 @@ from hypothesis import example, given from hypothesis.strategies import floats, integers, text from natsort.compat.fastnumbers import fast_float, fast_int from natsort.compat.locale import get_strxfrm -from natsort.ns_enum import NS_DUMB, NSType, ns +from natsort.ns_enum import NSType, NS_DUMB, ns from natsort.utils import groupletters, string_component_transform_factory # There are some unicode values that are known failures with the builtin locale diff --git a/tests/test_utils.py b/tests/test_utils.py index 448fa2c..38df303 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -94,13 +94,13 @@ def test_chain_functions_combines_functions_in_given_order() -> None: # and a test that uses the hypothesis module. -def test_groupletters_returns_letters_with_lowercase_transform_of_letter_example() -> None: +def test_groupletters_gives_letters_with_lowercase_letter_transform_example() -> None: assert utils.groupletters("HELLO") == "hHeElLlLoO" assert utils.groupletters("hello") == "hheelllloo" @given(text().filter(bool)) -def test_groupletters_returns_letters_with_lowercase_transform_of_letter( +def test_groupletters_gives_letters_with_lowercase_letter_transform( x: str, ) -> None: assert utils.groupletters(x) == "".join( @@ -134,7 +134,7 @@ def test_sep_inserter_inserts_separator_between_two_numbers( assert isinstance(result[i + 1], int) -def test_path_splitter_splits_path_string_by_separator_example() -> None: +def test_path_splitter_splits_path_string_by_sep_example() -> None: given = "/this/is/a/path" expected = (os.sep, "this", "is", "a", "path") assert tuple(utils.path_splitter(given)) == tuple(expected) @@ -142,19 +142,19 @@ def test_path_splitter_splits_path_string_by_separator_example() -> None: @given(lists(sampled_from(string.ascii_letters), min_size=2).filter(all)) -def test_path_splitter_splits_path_string_by_separator(x: List[str]) -> None: +def test_path_splitter_splits_path_string_by_sep(x: List[str]) -> None: z = str(pathlib.Path(*x)) assert tuple(utils.path_splitter(z)) == tuple(pathlib.Path(z).parts) -def test_path_splitter_splits_path_string_by_separator_and_removes_extension_example() -> None: +def test_path_splitter_splits_path_string_by_sep_and_removes_extension_example() -> None: given = "/this/is/a/path/file.x1.10.tar.gz" expected = (os.sep, "this", "is", "a", "path", "file.x1.10", ".tar", ".gz") assert tuple(utils.path_splitter(given)) == tuple(expected) @given(lists(sampled_from(string.ascii_letters), min_size=3).filter(all)) -def test_path_splitter_splits_path_string_by_separator_and_removes_extension( +def test_path_splitter_splits_path_string_by_sep_and_removes_extension( x: List[str], ) -> None: z = str(pathlib.Path(*x[:-2])) + "." + x[-1] |