diff options
-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", [ |