MCPcopy Create free account
hub / github.com/openai/openai-python / test_translation_create_overloads_in_sync

Function test_translation_create_overloads_in_sync

tests/lib/test_audio.py:19–50  ·  view source on GitHub ↗
(sync: bool, client: OpenAI, async_client: AsyncOpenAI)

Source from the content-addressed store, hash-verified

17
18@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])
19def test_translation_create_overloads_in_sync(sync: bool, client: OpenAI, async_client: AsyncOpenAI) -> None:
20 checking_client: OpenAI | AsyncOpenAI = client if sync else async_client
21
22 fn = checking_client.audio.translations.create
23 overload_response_formats: set[str] = set()
24
25 for i, overload in enumerate(typing_extensions.get_overloads(fn)):
26 assert_signatures_in_sync(
27 fn,
28 overload,
29 exclude_params={"response_format", "stream"},
30 description=f" for overload {i}",
31 )
32
33 sig = inspect.signature(overload)
34 typ = evaluate_forwardref(
35 sig.parameters["response_format"].annotation,
36 globalns=sys.modules[fn.__module__].__dict__,
37 )
38 if is_union_type(typ):
39 for arg in get_args(typ):
40 if not is_literal_type(arg):
41 continue
42
43 overload_response_formats.update(get_args(arg))
44 elif is_literal_type(typ):
45 overload_response_formats.update(get_args(typ))
46
47 # 'diarized_json' applies only to transcriptions, not translations.
48 src_response_formats: set[str] = set(get_args(AudioResponseFormat)) - {"diarized_json"}
49 diff = src_response_formats.difference(overload_response_formats)
50 assert len(diff) == 0, f"some response format options don't have overloads"
51
52
53@pytest.mark.parametrize("sync", [True, False], ids=["sync", "async"])

Callers

nothing calls this directly

Calls 6

evaluate_forwardrefFunction · 0.90
is_union_typeFunction · 0.90
is_literal_typeFunction · 0.90
get_argsFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected