summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authord-kiss <speakupness@gmail.com>2018-02-03 19:18:04 +0200
committerd-kiss <speakupness@gmail.com>2018-02-03 19:18:04 +0200
commit81b6decf8accf4df4f166eda3615d1ed58b1efb8 (patch)
treea03ffcf87b52f2db92617b0f80b755a9736c7ba0
parent16a369d83fbd63c4fd1b5c2fbfd88947ae91faad (diff)
downloadnatsort-81b6decf8accf4df4f166eda3615d1ed58b1efb8.tar.gz
Added coverage to the caching mechanism.
-rw-r--r--test_natsort/test_natsort_cmp.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/test_natsort/test_natsort_cmp.py b/test_natsort/test_natsort_cmp.py
index 4f544e0..d2e9e72 100644
--- a/test_natsort/test_natsort_cmp.py
+++ b/test_natsort/test_natsort_cmp.py
@@ -41,6 +41,20 @@ def test__classes_can_be_compared():
@pytest.mark.skipif(PY_VERSION >= 3.0, reason='cmp() deprecated in Python 3')
+def test__keys_are_being_cached():
+ natcmp.cached_keys = {}
+ assert len(natcmp.cached_keys) == 0
+ natcmp(0, 0)
+ 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)
+ assert len(natcmp.cached_keys) == 2
+ natcmp(0, 0, alg=ns.FLOAT | ns.IGNORECASE | ns.LOCALEALPHA)
+ assert len(natcmp.cached_keys) == 2
+
+
+@pytest.mark.skipif(PY_VERSION >= 3.0, reason='cmp() deprecated in Python 3')
def test__classes_can_utilize_max_or_min():
comparables = [Comparable(i) for i in range(10)]