Skip to content

Commit 25bb909

Browse files
committed
Try to fix OpenAI responses tests
1 parent dad7bf7 commit 25bb909

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

sdk/ai/azure-ai-projects/tests/responses/test_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
class TestResponses(TestBase):
1414

1515
# To run this test:
16-
# pytest tests\agents\test_responses.py::TestResponses::test_responses -s
16+
# pytest tests\responses\test_responses.py::TestResponses::test_responses -s
1717
@servicePreparer()
1818
@recorded_by_proxy_httpx
1919
def test_responses(self, **kwargs):

sdk/ai/azure-ai-projects/tests/responses/test_responses_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class TestResponsesAsync(TestBase):
1313

1414
# To run this test:
15-
# pytest tests\agents\test_responses_async.py::TestResponsesAsync::test_responses_async -s
15+
# pytest tests\responses\test_responses_async.py::TestResponsesAsync::test_responses_async -s
1616
@servicePreparer()
1717
@recorded_by_proxy_async_httpx
1818
async def test_responses_async(self, **kwargs):

sdk/ai/azure-ai-projects/tests/test_base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,12 @@ def transform_httpx_request(request: httpx.Request, recording_id: str) -> None:
469469
request.headers["x-recording-id"] = recording_id
470470
request.headers["x-recording-mode"] = "record" if is_live_internal() else "playback"
471471

472+
# Remove all request headers that start with `x-stainless`, since they contain CPU info, OS info, etc.
473+
# Those change depending on which machine the tests are run on, so we cannot have a single test recording with those.
474+
headers_to_remove = [key for key in request.headers.keys() if key.lower().startswith("x-stainless")]
475+
for header in headers_to_remove:
476+
del request.headers[header]
477+
472478
# Rewrite URL to proxy
473479
updated_target = parsed_result._replace(**get_proxy_netloc()).geturl()
474480
request.url = httpx.URL(updated_target)
@@ -567,6 +573,12 @@ def transform_httpx_request(request: httpx.Request, recording_id: str) -> None:
567573
request.headers["x-recording-id"] = recording_id
568574
request.headers["x-recording-mode"] = "record" if is_live_internal() else "playback"
569575

576+
# Remove all request headers that start with `x-stainless`, since they contain CPU info, OS info, etc.
577+
# Those change depending on which machine the tests are run on, so we cannot have a single test recording with those.
578+
headers_to_remove = [key for key in request.headers.keys() if key.lower().startswith("x-stainless")]
579+
for header in headers_to_remove:
580+
del request.headers[header]
581+
570582
# Rewrite URL to proxy
571583
updated_target = parsed_result._replace(**get_proxy_netloc()).geturl()
572584
request.url = httpx.URL(updated_target)

0 commit comments

Comments
 (0)