From 2ab858115ed93415bf9aaed6c18144041ecb0876 Mon Sep 17 00:00:00 2001 From: Ryan Auld Date: Mon, 22 Jun 2026 11:35:26 -0700 Subject: [PATCH] Fix Python 3.14 test timeout: replace utcnow() and remove tee pipe - Replace deprecated datetime.utcnow() with datetime.now(timezone.utc) to eliminate DeprecationWarning on Python 3.14+ - Replace '2>&1 | tee' with pytest --log-file to avoid pipe deadlock that caused the test step to stall until the 5-min timeout Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .Pipelines/template-pipeline-stages.yml | 5 ++--- msal/wstrust_request.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.Pipelines/template-pipeline-stages.yml b/.Pipelines/template-pipeline-stages.yml index b763f01a..0b6b9742 100644 --- a/.Pipelines/template-pipeline-stages.yml +++ b/.Pipelines/template-pipeline-stages.yml @@ -121,16 +121,15 @@ stages: --benchmark-skip \ --timeout=120 \ --junitxml=test-results/junit-unit.xml \ + --log-file=test-results/pytest-unit.log \ --ignore=tests/test_e2e.py \ --ignore=tests/test_e2e_manual.py \ --ignore=tests/test_fmi_e2e.py \ --deselect tests/test_cryptography.py::CryptographyTestCase::test_ceiling_should_be_latest_cryptography_version_plus_three \ - --deselect tests/test_cryptography.py::CryptographyTestCase::test_should_be_run_with_latest_version_of_cryptography \ - 2>&1 | tee test-results/pytest-unit.log + --deselect tests/test_cryptography.py::CryptographyTestCase::test_should_be_run_with_latest_version_of_cryptography displayName: 'Run pytest (unit)' timeoutInMinutes: 5 env: - # Force unbuffered stdout so ADO logs stream in real time through the tee pipe. PYTHONUNBUFFERED: '1' # Run cryptography version-gating tests separately as a warning-only check. diff --git a/msal/wstrust_request.py b/msal/wstrust_request.py index 159375f3..56b0b82d 100644 --- a/msal/wstrust_request.py +++ b/msal/wstrust_request.py @@ -26,7 +26,7 @@ #------------------------------------------------------------------------------ import uuid -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import logging from .mex import Mex @@ -76,7 +76,7 @@ def wsu_time_format(datetime_obj): def _build_rst(username, password, cloud_audience_urn, endpoint_address, soap_action): - now = datetime.utcnow() + now = datetime.now(timezone.utc) return """ {soap_action}