diff --git a/tests/debug_test.py b/tests/debug_test.py index f4f983b9..a1d465c3 100644 --- a/tests/debug_test.py +++ b/tests/debug_test.py @@ -18,7 +18,7 @@ def debug_session_factory(*args, **kwargs) -> httpx.Client: p = api._.find_pet_by_id(data={}, parameters={"id": 1}) -@pytest.mark.asyncio +@pytest.mark.asyncio(loop_scope="session") async def test_debug_log_async(httpx_mock, petstore_expanded): httpx_mock.add_response(headers={"Content-Type": "application/json"}, json={"foo": 1}) diff --git a/tests/schema_test.py b/tests/schema_test.py index 69686a4a..f79ecb8a 100644 --- a/tests/schema_test.py +++ b/tests/schema_test.py @@ -369,24 +369,24 @@ def test_schema_discriminated_union_invalid_array(with_schema_discriminated_unio def test_schema_discriminated_union_warnings(with_schema_discriminated_union_warning, openapi_version): from aiopenapi3.errors import DiscriminatorWarning - with pytest.warns( - DiscriminatorWarning, match=r"Discriminated Union member \S+ without const/enum key property \S+" - ): - api = OpenAPI("/", with_schema_discriminated_union_warning) - - with pytest.warns( - DiscriminatorWarning, - match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+", + with ( + pytest.warns( + DiscriminatorWarning, + match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+", + ), + pytest.warns(DiscriminatorWarning, match=r"Discriminated Union member \S+ without const/enum key property \S+"), ): api = OpenAPI("/", with_schema_discriminated_union_warning) if (openapi_version.major, openapi_version.minor, openapi_version.patch) >= (3, 1, 0): s = copy.deepcopy(with_schema_discriminated_union_warning) - # del s["components"]["schemas"]["C"]["properties"]["object_type"]["enum"] - s["components"]["schemas"]["C"]["properties"]["object_type"]["const"] = "f" + del s["components"]["schemas"]["B"]["properties"]["object_type"]["enum"] + s["components"]["schemas"]["B"]["properties"]["object_type"]["enum"] = ["f"] + s["components"]["schemas"]["A"]["properties"]["object_type"]["enum"] = ["a"] + s["components"]["schemas"]["C"]["properties"]["object_type"]["const"] = "c" with pytest.warns( DiscriminatorWarning, - match=r"Discriminated Union member key property const mismatches property mapping \S+ \!= \S+", + match=r"Discriminated Union member key property enum mismatches property mapping \S+ \!= \S+", ): api = OpenAPI("/", s) @@ -493,6 +493,7 @@ def test_schema_enum_array(with_schema_enum_array): api = OpenAPI("/", with_schema_enum_array) +@pytest.mark.httpx_mock(can_send_already_matched_responses=True) def test_schema_pathitems(httpx_mock, with_schema_pathitems): httpx_mock.add_response(headers={"Content-Type": "application/json"}, json={"foo": "bar"}) api = OpenAPI("/", with_schema_pathitems, session_factory=httpx.Client)