diff options
author | Seth Morton <seth.m.morton@gmail.com> | 2021-12-09 21:34:23 -0800 |
---|---|---|
committer | Seth Morton <seth.m.morton@gmail.com> | 2021-12-09 22:21:46 -0800 |
commit | e986a05f61f39fcac70782c7e6428e95e2bad6e9 (patch) | |
tree | 00f9466ea601298d9ce17ec1660c48dc1f2222f3 | |
parent | 40a3f6c625e5e58d4c303c4366e7df2448852943 (diff) | |
download | natsort-e986a05f61f39fcac70782c7e6428e95e2bad6e9.tar.gz |
Add tests for the cs_CZ regression
This ensures that going forward this won't not sort correctly.
-rw-r--r-- | tests/conftest.py | 16 | ||||
-rw-r--r-- | tests/test_natsorted.py | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index c63e149..6cd922b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -48,3 +48,19 @@ def with_locale_de_de() -> Iterator[None]: yield finally: locale.setlocale(locale.LC_ALL, orig) + + +@pytest.fixture() +def with_locale_cs_cz() -> Iterator[None]: + """ + Convenience to load the cs_CZ locale - reset when complete - skip if missing. + """ + orig = locale.getlocale() + try: + load_locale("cs_CZ") + except locale.Error: + pytest.skip("requires cs_CZ locale to be installed") + else: + yield + finally: + locale.setlocale(locale.LC_ALL, orig) diff --git a/tests/test_natsorted.py b/tests/test_natsorted.py index d043ab4..4a64a27 100644 --- a/tests/test_natsorted.py +++ b/tests/test_natsorted.py @@ -251,6 +251,14 @@ def test_natsorted_locale_bug_regression_test_109() -> None: assert natsorted(given, alg=ns.LOCALE) == expected +@pytest.mark.usefixtures("with_locale_cs_cz") +def test_natsorted_locale_bug_regression_test_140() -> None: + # https://github.com/SethMMorton/natsort/issues/140 + given = ["Aš", "Cheb", "Česko", "Cibulov", "Znojmo", "Žilina"] + expected = ["Aš", "Cibulov", "Česko", "Cheb", "Znojmo", "Žilina"] + assert natsorted(given, alg=ns.LOCALE) == expected + + @pytest.mark.parametrize( "alg, expected", [ |