mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Test cache usage
This commit is contained in:
parent
cd4f231d74
commit
0abd0d88ee
@ -88,7 +88,7 @@ def is_cache_up_to_date(cache_path):
|
||||
return False
|
||||
|
||||
|
||||
def path_to_dictionary(dictionary_name):
|
||||
def path_to_dictionary(dictionary_name, cache_callback=None):
|
||||
cd = getattr(path_to_dictionary, 'cache_dir', None) or cache_dir()
|
||||
cache_path = os.path.join(cd, 'hyphenation')
|
||||
try:
|
||||
@ -98,4 +98,6 @@ def path_to_dictionary(dictionary_name):
|
||||
raise
|
||||
if not is_cache_up_to_date(cache_path):
|
||||
extract_dicts(cache_path)
|
||||
if cache_callback is not None:
|
||||
cache_callback()
|
||||
return os.path.join(cache_path, 'f', dictionary_name)
|
||||
|
@ -45,9 +45,21 @@ class TestHyphenation(unittest.TestCase):
|
||||
t('nl', 'nl_NL')
|
||||
t('fr', 'fr')
|
||||
t('XXX')
|
||||
|
||||
cache = [False]
|
||||
|
||||
def cache_callback():
|
||||
cache[0] = True
|
||||
|
||||
self.assertTrue(
|
||||
os.path.exists(path_to_dictionary(dictionary_name_for_locale('en')))
|
||||
os.path.exists(path_to_dictionary(dictionary_name_for_locale('en'), cache_callback))
|
||||
)
|
||||
self.assertTrue(cache[0])
|
||||
cache[0] = False
|
||||
self.assertTrue(
|
||||
os.path.exists(path_to_dictionary(dictionary_name_for_locale('es'), cache_callback))
|
||||
)
|
||||
self.assertFalse(cache[0])
|
||||
|
||||
|
||||
def find_tests():
|
||||
|
Loading…
x
Reference in New Issue
Block a user