From 75fff151e817f95a4c94cc8490cadbe69be70e12 Mon Sep 17 00:00:00 2001 From: Shagun Gupta <137595846+MissLostCodes@users.noreply.github.com> Date: Thu, 30 Oct 2025 18:52:34 +0530 Subject: [PATCH] fix(openai): replace pytest.warns(None) with warnings.catch_warnings in ChatOpenAI test to resolve TypeError . Resolves issue #33705 (#33741) --- .../openai/tests/unit_tests/chat_models/test_base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py index 0f01504e958..9dd15931c4d 100644 --- a/libs/partners/openai/tests/unit_tests/chat_models/test_base.py +++ b/libs/partners/openai/tests/unit_tests/chat_models/test_base.py @@ -3,6 +3,7 @@ from __future__ import annotations import json +import warnings from functools import partial from types import TracebackType from typing import Any, Literal, cast @@ -1199,14 +1200,18 @@ def test__get_request_payload() -> None: def test_init_o1() -> None: - with pytest.warns(None) as record: # type: ignore[call-overload] + with warnings.catch_warnings(record=True) as record: + warnings.simplefilter("error") # Treat warnings as errors ChatOpenAI(model="o1", reasoning_effort="medium") + assert len(record) == 0 def test_init_minimal_reasoning_effort() -> None: - with pytest.warns(None) as record: # type: ignore[call-overload] + with warnings.catch_warnings(record=True) as record: + warnings.simplefilter("error") ChatOpenAI(model="gpt-5", reasoning_effort="minimal") + assert len(record) == 0