diff options
author | d-kiss <speakupness@gmail.com> | 2018-02-03 19:38:50 +0200 |
---|---|---|
committer | d-kiss <speakupness@gmail.com> | 2018-02-03 19:38:50 +0200 |
commit | 217ae0ccdfdfa2947beddf9a9dfc7171f49252ef (patch) | |
tree | 603d5c7ef7dee5c0aec053069f6807d383fddf0c | |
parent | 81b6decf8accf4df4f166eda3615d1ed58b1efb8 (diff) | |
download | natsort-217ae0ccdfdfa2947beddf9a9dfc7171f49252ef.tar.gz |
Added locale dumb sort coverage.
-rw-r--r-- | test_natsort/test_natsort_cmp.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/test_natsort/test_natsort_cmp.py b/test_natsort/test_natsort_cmp.py index d2e9e72..4f04f45 100644 --- a/test_natsort/test_natsort_cmp.py +++ b/test_natsort/test_natsort_cmp.py @@ -6,6 +6,7 @@ Note that these tests are only relevant for Python version < 3. """ import sys from functools import partial +from mock import patch import pytest from hypothesis import given @@ -48,11 +49,35 @@ def test__keys_are_being_cached(): assert len(natcmp.cached_keys) == 1 natcmp(0, 0) assert len(natcmp.cached_keys) == 1 - natcmp(0, 0, alg=ns.FLOAT | ns.IGNORECASE | ns.LOCALEALPHA) + natcmp(0, 0, alg=ns.L) assert len(natcmp.cached_keys) == 2 - natcmp(0, 0, alg=ns.FLOAT | ns.IGNORECASE | ns.LOCALEALPHA) + + natcmp(0, 0, alg=ns.L) assert len(natcmp.cached_keys) == 2 + with patch('natsort.compat.locale.dumb_sort', return_value=True): + natcmp(0, 0, alg=ns.L) + + assert len(natcmp.cached_keys) == 3 + + with patch('natsort.compat.locale.dumb_sort', return_value=True): + natcmp(0, 0, alg=ns.L) + + assert len(natcmp.cached_keys) == 3 + + +@pytest.mark.skipif(PY_VERSION >= 3.0, reason='cmp() deprecated in Python 3') +def test__illegal_algorithm_raises_error(): + try: + natcmp(0, 0, alg="Just random stuff") + assert False + + except ValueError: + assert True + + except Exception: + assert False + @pytest.mark.skipif(PY_VERSION >= 3.0, reason='cmp() deprecated in Python 3') def test__classes_can_utilize_max_or_min(): |