Skip to content

Conversation

@bbc2
Copy link
Collaborator

@bbc2 bbc2 commented Jan 11, 2026

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.

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.
Comment on lines -173 to -182
@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")


Copy link
Collaborator Author

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.

Copy link

Copilot AI left a 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 sh module (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.

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.

1 participant