MCPcopy
hub / github.com/PDFMathTranslate/PDFMathTranslate / test_cache

Method test_cache

test/test_translator.py:32–50  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30 cache.clean_test_db(self.test_db)
31
32 def test_cache(self):
33 translator = AutoIncreaseTranslator("en", "zh", "test", False)
34 # First translation should be cached
35 text = "Hello World"
36 first_result = translator.translate(text)
37
38 # Second translation should return the same result from cache
39 second_result = translator.translate(text)
40 self.assertEqual(first_result, second_result)
41
42 # Different input should give different result
43 different_text = "Different Text"
44 different_result = translator.translate(different_text)
45 self.assertNotEqual(first_result, different_result)
46
47 # Test cache with ignore_cache=True
48 translator.ignore_cache = True
49 no_cache_result = translator.translate(text)
50 self.assertNotEqual(first_result, no_cache_result)
51
52 def test_add_cache_impact_parameters(self):
53 translator = AutoIncreaseTranslator("en", "zh", "test", False)

Callers

nothing calls this directly

Calls 2

translateMethod · 0.45

Tested by

no test coverage detected