Skip to content

Commit

Permalink
test(converter): remove test for translation functionality since the …
Browse files Browse the repository at this point in the history
…test has no practical significance

Although this test set the number of threads to 2, it did not test parallel translation paths.

This test was actually directly testing BaseTranslator.
  • Loading branch information
awwaawwa committed Dec 23, 2024
1 parent 53f426a commit ee8ae85
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions test/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,6 @@ def test_receive_layout(self, mock_receive_layout):
self.converter.receive_layout(mock_page)
mock_receive_layout.assert_called_once_with(mock_page)

@patch("concurrent.futures.ThreadPoolExecutor")
@patch("pdf2zh.cache")
def test_translation(self, mock_cache, mock_executor):
mock_executor.return_value.__enter__.return_value.map.return_value = [
"你好",
"{v1}",
]
mock_cache.deterministic_hash.return_value = "test_hash"
mock_cache.load_paragraph.return_value = None
mock_cache.write_paragraph.return_value = None

sstk = ["Hello", "{v1}"]
self.converter.thread = 2
results = []
with patch.object(self.converter, "translator") as mock_translator:
mock_translator.translate.side_effect = lambda x: (
"你好" if x == "Hello" else x
)
for s in sstk:
results.append(self.converter.translator.translate(s))
self.assertEqual(results, ["你好", "{v1}"])

def test_receive_layout_with_complex_formula(self):
ltpage = LTPage(1, (0, 0, 500, 500))
ltchar = Mock()
Expand Down

0 comments on commit ee8ae85

Please sign in to comment.