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

Function glossary_manager

tests/conftest.py:320–351  ·  view source on GitHub ↗

Fixture function that may be used to create context-managed test v2 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(glossar

(translator, glossary_name)

Source from the content-addressed store, hash-verified

318
319@pytest.fixture
320def glossary_manager(translator, glossary_name) -> CreateManagedGlossaryFunc:
321 """
322 Fixture function that may be used to create context-managed test v2
323 glossaries, named using the current test. May be called multiple times in
324 a test to create multiple glossaries, ideally with a different suffix for
325 each glossary.
326
327 Usage example:
328 def test_example(glossary_manager):
329 with glossary_manager(
330 entries={"a": "b"}, glossary_name_suffix="1"
331 ) as glossary1:
332 ...
333 """
334
335 def create_managed_glossary(
336 source_lang: str = "EN",
337 target_lang: str = "DE",
338 entries: Optional[dict] = None,
339 glossary_name_suffix: str = "",
340 ):
341 if not entries:
342 entries = {"Hello": "Hallo"}
343 return ManagedGlossary(
344 translator,
345 f"{glossary_name}{glossary_name_suffix}",
346 source_lang,
347 target_lang,
348 entries,
349 )
350
351 return create_managed_glossary
352
353
354@pytest.fixture

Callers 13

test_glossary_getFunction · 0.85
test_glossary_listFunction · 0.85
test_glossary_entriesFunction · 0.85
test_glossary_deleteFunction · 0.85
test_glossary_getFunction · 0.85
test_glossary_listFunction · 0.85
test_glossary_deleteFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected