Skip to content

[python] Fix test_sensitive_word failing on Windows#10300

Merged
msyyc merged 3 commits into
mainfrom
python/fix-windows-sensitive-word-test
Apr 8, 2026
Merged

[python] Fix test_sensitive_word failing on Windows#10300
msyyc merged 3 commits into
mainfrom
python/fix-windows-sensitive-word-test

Conversation

@msyyc
Copy link
Copy Markdown
Contributor

@msyyc msyyc commented Apr 8, 2026

Problem

test_sensitive_word in test_unbranded.py fails on Windows CI because the check_sensitive_word function uses PowerShell Select-String which outputs relative paths, while the regex expects absolute paths from folder.as_posix(). This causes the function to always return [] on Windows.

On Linux, grep outputs absolute paths so the test passes.

Fix

Replace the platform-specific shell commands (powershell Select-String / grep) with pure Python using pathlib.rglob + read_text. This is:

  • Cross-platform - works identically on Windows and Linux
  • Simpler - no shell escaping, regex parsing, or platform branching
  • Reliable - no dependency on shell output format

Replace shell-based search (powershell Select-String / grep) with pure
Python pathlib.rglob + read_text. The PowerShell implementation output
relative paths while the regex expected absolute paths, causing the test
to always return empty results on Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@msyyc msyyc added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 8, 2026
msyyc and others added 2 commits April 8, 2026 13:31
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

@typespec/http-client-python - internal ✏️

Fix test_sensitive_word failing on Windows by replacing shell-based search with pure Python pathlib implementation.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 8, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@10300

commit: 00df699

@azure-sdk
Copy link
Copy Markdown
Collaborator

azure-sdk commented Apr 8, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@msyyc msyyc added this pull request to the merge queue Apr 8, 2026
Merged via the queue into main with commit 442eaac Apr 8, 2026
36 checks passed
@msyyc msyyc deleted the python/fix-windows-sensitive-word-test branch April 8, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants