Skip to content

Fix Python 3.14 test timeout: replace utcnow() and remove tee pipe#934

Merged
Robbie-Microsoft merged 1 commit into
devfrom
ryauld/fix-py314-timeout
Jun 22, 2026
Merged

Fix Python 3.14 test timeout: replace utcnow() and remove tee pipe#934
Robbie-Microsoft merged 1 commit into
devfrom
ryauld/fix-py314-timeout

Conversation

@RyAuld

@RyAuld RyAuld commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Problem

Python 3.14 unit tests intermittently stall at 99% completion, hitting the 5-minute step timeout. The last output before the hang is:

\
##[warning]datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version.
\\

Root Cause

Two issues contribute:

  1. \datetime.utcnow()\ deprecation — emits a \DeprecationWarning\ on Python 3.12+ and is scheduled for removal in 3.14+
  2. \2>&1 | tee\ pipe deadlock — after pytest finishes, the pipe to \ ee\ can hang waiting for file descriptors to close on Python 3.14

Fix

  • Replace \datetime.utcnow()\ with \datetime.now(timezone.utc)\ in \msal/wstrust_request.py\ (compatible with Python 3.2+)
  • Replace \2>&1 | tee test-results/pytest-unit.log\ with pytest's native --log-file\ option, eliminating the pipe entirely

Testing

  • Local wstrust tests pass
  • CI results from this PR will confirm the fix across all Python versions

- 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>
Copilot AI review requested due to automatic review settings June 22, 2026 18:35
@RyAuld RyAuld requested a review from a team as a code owner June 22, 2026 18:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses intermittent CI timeouts on Python 3.14 by removing a deprecated datetime.utcnow() usage that emits warnings, and by eliminating a shell tee pipeline that can hang at the end of the unit test run.

Changes:

  • Replace datetime.utcnow() with timezone-aware datetime.now(timezone.utc) in WS-Trust request timestamp generation.
  • Update the unit-test Azure Pipelines step to use pytest’s --log-file instead of 2>&1 | tee, removing the pipe.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
msal/wstrust_request.py Avoids deprecated utcnow() by generating UTC timestamps via datetime.now(timezone.utc).
.Pipelines/template-pipeline-stages.yml Removes tee piping from the unit-test pytest invocation and writes logs via --log-file instead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Robbie-Microsoft Robbie-Microsoft merged commit bfd7fb7 into dev Jun 22, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants