Capture pytest conftest warnings#1008
Merged
Merged
Conversation
… are captured even though they are prior to individual tests
for more information, see https://pre-commit.ci
Contributor
There was a problem hiding this comment.
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()withwarnings.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.
motus
approved these changes
Oct 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Title
Capture pytest conftest warnings
Description
Followup to #1007.
Copilot suggestions were correct. The
logger.warning()messages generated in__init__.pyandconftest.pyare captured, but not emitted by default when per-test captures are done.This switches those calls to
UserWarningsso they are always captured.This was the only location I could find for those.
Additionally, I adjust some checks for the
docker.sockon Windows to avoid some warnings.Type of Change
Testing
Manual.