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

Function cleanup_matching_glossaries

tests/conftest.py:209–232  ·  view source on GitHub ↗

Fixture function to remove all glossaries from the server matching the given predicate. Can be used, for example, to remove all glossaries with a matching name. Usage example: def test_example(cleanup_matching_glossaries): ... cleanup_matching_glossa

(deepl_client)

Source from the content-addressed store, hash-verified

207
208@pytest.fixture
209def cleanup_matching_glossaries(deepl_client):
210 """
211 Fixture function to remove all glossaries from the server matching the
212 given predicate. Can be used, for example, to remove all glossaries with a
213 matching name.
214
215 Usage example:
216 def test_example(cleanup_matching_glossaries):
217 ...
218 cleanup_matching_glossaries(
219 lambda glossary: glossary.name.startswith("test ")
220 )
221 """
222
223 def do_cleanup(predicate: Callable[[deepl.GlossaryInfo], bool]):
224 glossaries = deepl_client.list_multilingual_glossaries()
225 for glossary in glossaries:
226 if predicate(glossary):
227 try:
228 deepl_client.delete_multilingual_glossary(glossary)
229 except deepl.DeepLException:
230 pass
231
232 return do_cleanup
233
234
235class ManagedGlossary:

Callers 10

test_glossary_createFunction · 0.85
test_glossary_createFunction · 0.85
test_glossary_create_csvFunction · 0.85
test_glossary_createFunction · 0.85
test_glossary_create_csvFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected