From 08af5e2bab184c1b5d357ebde8c0efdbe6288e2c Mon Sep 17 00:00:00 2001 From: Aarni Koskela Date: Tue, 7 Feb 2023 16:00:41 +0200 Subject: Replace babel.localedata.locale_identifiers cache with LRU cache --- tests/test_localedata.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/test_localedata.py b/tests/test_localedata.py index 913922e..75c34b1 100644 --- a/tests/test_localedata.py +++ b/tests/test_localedata.py @@ -110,18 +110,15 @@ def test_locale_identifiers_cache(monkeypatch): rv = original_listdir(*args) listdir_calls.append((args, rv)) return rv - monkeypatch.setattr(localedata.os, 'listdir', listdir_spy) - - # In case we've already run some tests... - if hasattr(localedata.locale_identifiers, 'cache'): - del localedata.locale_identifiers.cache + monkeypatch.setattr(localedata.os, 'listdir', listdir_spy) + localedata.locale_identifiers.cache_clear() assert not listdir_calls - assert localedata.locale_identifiers() + l = localedata.locale_identifiers() assert len(listdir_calls) == 1 - assert localedata.locale_identifiers() is localedata.locale_identifiers.cache + assert localedata.locale_identifiers() is l assert len(listdir_calls) == 1 - localedata.locale_identifiers.cache = None + localedata.locale_identifiers.cache_clear() assert localedata.locale_identifiers() assert len(listdir_calls) == 2 -- cgit v1.2.1