mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fix failing test
This commit is contained in:
parent
a8cb5c96ba
commit
9d9cd957f2
@ -77,7 +77,7 @@ def extract_dicts(cache_path):
|
|||||||
|
|
||||||
|
|
||||||
def is_cache_up_to_date(cache_path):
|
def is_cache_up_to_date(cache_path):
|
||||||
if hasattr(is_cache_up_to_date, 'updated'):
|
if getattr(is_cache_up_to_date, 'updated', False):
|
||||||
return True
|
return True
|
||||||
hsh = P('hyphenation/sha1sum', data=True)
|
hsh = P('hyphenation/sha1sum', data=True)
|
||||||
try:
|
try:
|
||||||
|
@ -10,7 +10,7 @@ import unittest
|
|||||||
|
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
from calibre.utils.hyphenation.dictionaries import (
|
from calibre.utils.hyphenation.dictionaries import (
|
||||||
dictionary_name_for_locale, get_cache_path, path_to_dictionary
|
dictionary_name_for_locale, get_cache_path, path_to_dictionary, is_cache_up_to_date
|
||||||
)
|
)
|
||||||
from calibre.utils.hyphenation.hyphenate import (
|
from calibre.utils.hyphenation.hyphenate import (
|
||||||
add_soft_hyphens, dictionary_for_locale, remove_punctuation
|
add_soft_hyphens, dictionary_for_locale, remove_punctuation
|
||||||
@ -21,17 +21,19 @@ class TestHyphenation(unittest.TestCase):
|
|||||||
|
|
||||||
ae = unittest.TestCase.assertEqual
|
ae = unittest.TestCase.assertEqual
|
||||||
|
|
||||||
def setUp(cls):
|
def setUp(self):
|
||||||
tdir = PersistentTemporaryDirectory()
|
tdir = PersistentTemporaryDirectory()
|
||||||
path_to_dictionary.cache_dir = tdir
|
path_to_dictionary.cache_dir = tdir
|
||||||
dictionary_name_for_locale.cache_clear()
|
dictionary_name_for_locale.cache_clear()
|
||||||
dictionary_for_locale.cache_clear()
|
dictionary_for_locale.cache_clear()
|
||||||
get_cache_path.cache_clear()
|
get_cache_path.cache_clear()
|
||||||
|
is_cache_up_to_date.updated = False
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
dictionary_name_for_locale.cache_clear()
|
dictionary_name_for_locale.cache_clear()
|
||||||
dictionary_for_locale.cache_clear()
|
dictionary_for_locale.cache_clear()
|
||||||
get_cache_path.cache_clear()
|
get_cache_path.cache_clear()
|
||||||
|
is_cache_up_to_date.updated = False
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(path_to_dictionary.cache_dir)
|
shutil.rmtree(path_to_dictionary.cache_dir)
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
@ -59,8 +61,9 @@ class TestHyphenation(unittest.TestCase):
|
|||||||
def cache_callback():
|
def cache_callback():
|
||||||
cache[0] = True
|
cache[0] = True
|
||||||
|
|
||||||
|
dp = path_to_dictionary(dictionary_name_for_locale('en'), cache_callback)
|
||||||
self.assertTrue(
|
self.assertTrue(
|
||||||
os.path.exists(path_to_dictionary(dictionary_name_for_locale('en'), cache_callback))
|
os.path.exists(dp), 'The dictionary {} does not exist'.format(dp)
|
||||||
)
|
)
|
||||||
self.assertTrue(cache[0])
|
self.assertTrue(cache[0])
|
||||||
cache[0] = False
|
cache[0] = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user