Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Capture pytest conftest warnings#1008

Merged
bpkroth merged 8 commits into
microsoft:mainfrom
bpkroth:pytest-tweaks-for-windows
Oct 23, 2025
Merged

Capture pytest conftest warnings#1008
bpkroth merged 8 commits into
microsoft:mainfrom
bpkroth:pytest-tweaks-for-windows

Conversation

@bpkroth

@bpkroth bpkroth commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

Pull Request

Title

Capture pytest conftest warnings


Description

Followup to #1007.

Copilot suggestions were correct. The logger.warning() messages generated in __init__.py and conftest.py are captured, but not emitted by default when per-test captures are done.

This switches those calls to UserWarnings so they are always captured.

This was the only location I could find for those.

Additionally, I adjust some checks for the docker.sock on Windows to avoid some warnings.


Type of Change

  • 🛠️ Bug fix
  • 🧪 Tests

Testing

Manual.


@bpkroth bpkroth requested a review from a team as a code owner October 23, 2025 18:30
Copilot AI review requested due to automatic review settings October 23, 2025 18:30

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 updates warning emissions in test configuration files to use Python's warnings.warn() with UserWarning instead of logging.warning(). This ensures warnings are properly captured during pytest execution, particularly when per-test capture is enabled. Additionally, it includes platform-specific handling for Docker socket paths and checks on Windows to avoid unnecessary warnings.

Key Changes:

  • Replaced logging.warning() with warnings.warn(..., UserWarning) in test infrastructure files
  • Added Windows-specific Docker socket path handling to prevent warnings on that platform
  • Added platform check before calling POSIX-specific functions like os.getuid()

Reviewed Changes

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

File Description
mlos_viz/mlos_viz/tests/conftest.py Converted logging warnings to UserWarnings for Tcl/Tk environment variable setup
mlos_bench/mlos_bench/tests/init.py Converted logging warnings to UserWarnings and added Windows-specific handling for Docker socket checks

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread mlos_viz/mlos_viz/tests/conftest.py
Comment thread mlos_bench/mlos_bench/tests/__init__.py
@bpkroth bpkroth enabled auto-merge (squash) October 23, 2025 18:31
@bpkroth bpkroth merged commit 04447c8 into microsoft:main Oct 23, 2025
23 of 31 checks passed
@bpkroth bpkroth deleted the pytest-tweaks-for-windows branch October 23, 2025 21:25
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