-
Notifications
You must be signed in to change notification settings - Fork 492
Add Windows testing to CI #604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Changes for users: none.
Notes:
- This adds CI testing with lowest and highest Python versions we
support.
- The main motivation for this is that we have Windows-specific code I'm
worried I might break with improvements, like improvements in `dotenv
run` error handling (coming soon).
- I went for the least intrusive changes for now, and disabled tests
which would fail unless they were trivial to adjust.
- We have tests using `sh` (Unix-only module) which should be possible
to fix later. Those tests are disabled on Windows.
- Also tests relying on the fact that environment variables are case
sensitive, which isn't the case on Windows. This is going to be more
tricky to fix. Those tests are also disabled on Windows.
- To check for the platform, I used `sys.platform == "win32"`
everywhere, which seems to be the best practice.
| @pytest.mark.skipif( | ||
| os.geteuid() == 0, reason="Root user can access files even with 000 permissions." | ||
| ) | ||
| def test_set_key_unauthorized_file(dotenv_path): | ||
| dotenv_path.chmod(0o000) | ||
|
|
||
| with pytest.raises(PermissionError): | ||
| dotenv.set_key(dotenv_path, "a", "x") | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI this test is a duplicate of test test_set_key_permission_error. It seems to have been introduced a long time ago when I refactored testing.
There was a problem hiding this comment.
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 adds Windows CI testing to ensure compatibility with Windows-specific code and prevent regressions. The changes focus on making the test suite platform-aware by conditionally importing Unix-only modules and skipping tests that rely on Unix-specific features or case-sensitive environment variables.
Changes:
- Added Windows testing to CI workflow for Python 3.9 and 3.14 (lowest and highest supported versions)
- Conditionally imported
shmodule (Unix-only) and skipped tests using it on Windows - Adapted permission error tests to work on both Windows and Unix with platform-specific chmod values
- Skipped tests that assume case-sensitive environment variable names on Windows
- Standardized platform detection to use
sys.platform == "win32"throughout
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/test.yml |
Added Windows testing matrix entries for Python 3.9 and 3.14 |
tests/test_zip_imports.py |
Conditional import of sh module and skipif decorator for Windows |
tests/test_main.py |
Conditional sh import, platform-specific permission handling, case-sensitivity test skips, and removal of duplicate permission test |
tests/test_ipython.py |
Skipped case-sensitive variable tests on Windows |
tests/test_fifo_dotenv.py |
Standardized platform check from startswith("win") to == "win32" |
tests/test_cli.py |
Conditional sh import and skipif decorators for sh-dependent tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes for users: none.
Notes:
dotenv runerror handling (coming soon).sh(Unix-only module) which should be possible to fix later. Those tests are disabled on Windows.sys.platform == "win32"everywhere, which seems to be the best practice.