Skip to content

Commit 5906595

Browse files
authored
Modify azure-communication conftest to apply a customdefault matcher on python 3.14 (#43719)
* modify azure-communication conftest to apply a customdefault matcher that ignores the Accept-Encoding header VALUE only on python 314
1 parent 73158a0 commit 5906595

File tree

7 files changed

+57
-2
lines changed

7 files changed

+57
-2
lines changed

sdk/communication/azure-communication-callautomation/tests/conftest.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6+
import sys
67
import pytest
78
import os
89
import asyncio
@@ -14,15 +15,21 @@
1415
add_body_key_sanitizer,
1516
add_general_string_sanitizer,
1617
remove_batch_sanitizers,
18+
set_custom_default_matcher
1719
)
1820

1921

2022
# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method
2123
@pytest.fixture(scope="session", autouse=True)
2224
def start_proxy(test_proxy):
23-
2425
set_default_session_settings()
2526

27+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
28+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
29+
if sys.version_info >= (3, 14):
30+
headers_to_ignore = "Accept-Encoding"
31+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
32+
2633
fake_connection_str = "endpoint=https://sanitized.communication.azure.com/;accesskey=fake=="
2734
connection_str = os.getenv("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING", fake_connection_str)
2835
add_general_string_sanitizer(target=connection_str, value=fake_connection_str)

sdk/communication/azure-communication-identity/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
# cSpell:ignore ests
2828
import pytest
2929
import os
30+
import sys
3031
from devtools_testutils import (
32+
set_custom_default_matcher,
3133
test_proxy,
3234
add_general_regex_sanitizer,
3335
add_header_regex_sanitizer,
@@ -42,6 +44,13 @@
4244
@pytest.fixture(scope="session", autouse=True)
4345
def add_sanitizers(test_proxy):
4446
set_default_session_settings()
47+
48+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
49+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
50+
if sys.version_info >= (3, 14):
51+
headers_to_ignore = "Accept-Encoding"
52+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
53+
4554
add_oauth_response_sanitizer()
4655

4756
connection_str = os.environ.get("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING")

sdk/communication/azure-communication-jobrouter/tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
add_uri_regex_sanitizer,
3737
add_body_key_sanitizer,
3838
remove_batch_sanitizers,
39+
set_custom_default_matcher
3940
)
4041
from router_test_constants import SANITIZED, FAKE_FUNCTION_URI, FAKE_ENDPOINT, FAKE_CONNECTION_STRING
4142
from azure.communication.jobrouter._shared.utils import parse_connection_str
@@ -49,6 +50,12 @@
4950
def start_proxy(test_proxy):
5051
set_default_session_settings()
5152

53+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
54+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
55+
if sys.version_info >= (3, 14):
56+
headers_to_ignore = "Accept-Encoding"
57+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
58+
5259
communication_connection_string = os.getenv(
5360
"COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING", FAKE_CONNECTION_STRING
5461
)

sdk/communication/azure-communication-messages/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
# cSpell:ignore ests
2828
import pytest
2929
import os
30+
import sys
3031
from devtools_testutils import (
32+
set_custom_default_matcher,
3133
test_proxy,
3234
add_header_regex_sanitizer,
3335
set_default_session_settings,
@@ -43,6 +45,13 @@
4345
@pytest.fixture(scope="session", autouse=True)
4446
def start_proxy(test_proxy):
4547
set_default_session_settings()
48+
49+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
50+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
51+
if sys.version_info >= (3, 14):
52+
headers_to_ignore = "Accept-Encoding"
53+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
54+
4655
add_oauth_response_sanitizer()
4756

4857
FAKE_CONNECTION_STRING = "endpoint=https://sanitized.unitedstates.ppe.communication.azure.net/;accesskey=fake==="

sdk/communication/azure-communication-rooms/tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
# --------------------------------------------------------------------------
2626
import pytest
2727
import os
28+
import sys
2829
from devtools_testutils import (
2930
add_general_string_sanitizer,
3031
add_header_regex_sanitizer,
3132
set_default_session_settings,
3233
remove_batch_sanitizers,
3334
add_uri_regex_sanitizer,
35+
set_custom_default_matcher
3436
)
3537
from azure.communication.rooms._shared.utils import parse_connection_str
3638

@@ -39,6 +41,12 @@
3941
def add_sanitizers(test_proxy):
4042
set_default_session_settings()
4143

44+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
45+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
46+
if sys.version_info >= (3, 14):
47+
headers_to_ignore = "Accept-Encoding"
48+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
49+
4250
communication_connection_string = os.getenv(
4351
"COMMUNICATION_CONNECTION_STRING_ROOMS", "endpoint=https://sanitized.communication.azure.com/;accesskey=fake==="
4452
)

sdk/communication/azure-communication-sms/tests/conftest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,29 @@
2727
# cSpell:ignore ests
2828
import pytest
2929
import os
30+
import sys
3031
from devtools_testutils import (
3132
test_proxy,
3233
add_header_regex_sanitizer,
3334
set_default_session_settings,
3435
add_body_key_sanitizer,
3536
add_oauth_response_sanitizer,
3637
add_general_string_sanitizer,
38+
set_custom_default_matcher
3739
)
3840
from azure.communication.sms._shared.utils import parse_connection_str
3941

4042

4143
@pytest.fixture(scope="session", autouse=True)
4244
def add_sanitizers(test_proxy):
4345
set_default_session_settings()
46+
47+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
48+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
49+
if sys.version_info >= (3, 14):
50+
headers_to_ignore = "Accept-Encoding"
51+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
52+
4453
add_oauth_response_sanitizer()
4554

4655
connection_str = os.environ.get("COMMUNICATION_LIVETEST_STATIC_CONNECTION_STRING")

sdk/communication/azure-communication-sms/tests/test_sms_client_e2e_async.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import pytest
1111
from devtools_testutils.aio import recorded_by_proxy_async
1212
from devtools_testutils.fake_credentials_async import AsyncFakeCredential
13-
from devtools_testutils import get_credential, is_live
13+
from devtools_testutils import get_credential, is_live, set_custom_default_matcher
1414
from azure.communication.sms.aio import SmsClient
1515
from azure.core.exceptions import HttpResponseError
1616
from _shared.utils import async_create_token_credential, get_http_logging_policy
@@ -22,6 +22,12 @@ class TestClientAsync(ACSSMSTestCase):
2222
def setup_method(self):
2323
super().setUp()
2424

25+
# On python 3.14, azure-core sends an additional 'Accept-Encoding' header value that causes playback issues.
26+
# By ignoring it, we can avoid really wonky mismatch errors, while still validating the other headers
27+
if sys.version_info >= (3, 14):
28+
headers_to_ignore = "Accept-Encoding"
29+
set_custom_default_matcher(ignored_headers=headers_to_ignore)
30+
2531
@recorded_by_proxy_async
2632
async def test_send_sms_single_async(self):
2733
sms_client = self.create_client_from_connection_string()

0 commit comments

Comments
 (0)