MCPcopy Create free account
hub / github.com/DeepL/deepl-python / test_glossary_translate_document

Function test_glossary_translate_document

tests/test_multilingual_glossary.py:449–468  ·  view source on GitHub ↗
(
    deepl_client,
    multilingual_glossary_manager,
    example_document_path,
    output_document_path,
)

Source from the content-addressed store, hash-verified

447
448
449def test_glossary_translate_document(
450 deepl_client,
451 multilingual_glossary_manager,
452 example_document_path,
453 output_document_path,
454):
455 input_text = "artist\nprize"
456 expected_output_text = "Maler\nGewinn"
457 example_document_path.write_text(input_text)
458 entries = {"artist": "Maler", "prize": "Gewinn"}
459 glossary_dict = MultilingualGlossaryDictionaryEntries("EN", "DE", entries)
460 with multilingual_glossary_manager([glossary_dict]) as glossary:
461 deepl_client.translate_document_from_filepath(
462 example_document_path,
463 output_path=output_document_path,
464 source_lang="EN",
465 target_lang="DE",
466 glossary=glossary,
467 )
468 assert expected_output_text == output_document_path.read_text()
469
470
471def test_glossary_translate_text_invalid(

Callers

nothing calls this directly

Tested by

no test coverage detected