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

Function multilingual_glossary_manager

tests/conftest.py:355–382  ·  view source on GitHub ↗

Fixture function that may be used to create context-managed test glossaries, named using the current test. May be called multiple times in a test to create multiple glossaries, ideally with a different suffix for each glossary. Usage example: def test_example(glossary_m

(
    deepl_client, glossary_name
)

Source from the content-addressed store, hash-verified

353
354@pytest.fixture
355def multilingual_glossary_manager(
356 deepl_client, glossary_name
357) -> CreateManagedMultilingualGlossaryFunc:
358 """
359 Fixture function that may be used to create context-managed test
360 glossaries, named using the current test. May be called multiple times in
361 a test to create multiple glossaries, ideally with a different suffix for
362 each glossary.
363
364 Usage example:
365 def test_example(glossary_manager):
366 with glossary_manager(
367 entries={"a": "b"}, glossary_name_suffix="1"
368 ) as glossary1:
369 ...
370 """
371
372 def create_managed_glossary(
373 dictionaries: List[MultilingualGlossaryDictionaryEntries],
374 glossary_name_suffix: str = "",
375 ):
376 return ManagedMultilingualGlossary(
377 deepl_client,
378 f"{glossary_name}{glossary_name_suffix}",
379 dictionaries,
380 )
381
382 return create_managed_glossary
383
384
385@pytest.fixture

Calls

no outgoing calls

Tested by

no test coverage detected