Clear caches per test rather than per class

This commit is contained in:
Kovid Goyal 2019-12-02 14:56:35 +05:30
parent 1e5de81544
commit a8cb5c96ba
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -21,16 +21,14 @@ class TestHyphenation(unittest.TestCase):
ae = unittest.TestCase.assertEqual ae = unittest.TestCase.assertEqual
@classmethod def setUp(cls):
def setUpClass(cls):
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()
@classmethod def tearDown(self):
def tearDownClass(cls):
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()
@ -71,12 +69,11 @@ class TestHyphenation(unittest.TestCase):
) )
self.assertFalse(cache[0]) self.assertFalse(cache[0])
def test_remove_punctuation(self): def test_add_soft_hyphens(self):
self.ae(remove_punctuation('word'), ('', 'word', '')) self.ae(remove_punctuation('word'), ('', 'word', ''))
self.ae(remove_punctuation('wo.rd.'), ('', 'wo.rd', '.')) self.ae(remove_punctuation('wo.rd.'), ('', 'wo.rd', '.'))
self.ae(remove_punctuation('"«word!!'), ('"«', 'word', '!!')) self.ae(remove_punctuation('"«word!!'), ('"«', 'word', '!!'))
def test_add_soft_hyphens(self):
dictionary = dictionary_for_locale('en') dictionary = dictionary_for_locale('en')
def t(word, expected): def t(word, expected):