Add compatibility helper for older Pytest versions#47
Draft
Conversation
The `tmp_path` fixture was introduced in Pytest 3.9. Include an explicit definition of that fixture for compatibility with those older Pytest versions. When we're ready to drop support, we can just remove the fixture.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #47 +/- ##
=======================================
Coverage 51.82% 51.82%
=======================================
Files 20 20
Lines 2678 2678
Branches 546 546
=======================================
Hits 1388 1388
Misses 971 971
Partials 319 319 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
j-rivero
requested changes
Apr 13, 2026
| import pytest | ||
|
|
||
|
|
||
| if getattr(pytest, 'version_tuple', ()) < (3, 9): |
There was a problem hiding this comment.
Seems like pytest.version_tuple is not exported in pytest 3.9–6.x, so getattr(pytest, "version_tuple", ()) < (3, 9) still evaluates true. This triggers an unfortunate chain of problems:
- On pytest 3.9.3 and 6.2.5, pytest.version_tuple is not exported.
- getattr(..., ()) returns ().
- In Python, () < (3, 9) is True.
- The compatibility fixture is defined even though pytest already provides tmp_path.
Checked locally with uv:
/tmp ❯ uv pip install "pytest<7.0"
Resolved 7 packages in 80ms
Prepared 4 packages in 84ms
Installed 4 packages in 4ms
+ attrs==26.1.0
+ py==1.11.0
+ pytest==6.2.5
+ toml==0.10.2
/tmp ❯ python3
Python 3.10.20 (main, Mar 20 2026, 00:33:12) [Clang 22.1.1 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pytest
>>> getattr(pytest, 'version_tuple', ()) < (3, 9)
True
>>> getattr(pytest, 'version_tuple', ())
()
Member
Author
There was a problem hiding this comment.
😞 that's a bummer. I'll have a closer look. Thanks!
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.
The
tmp_pathfixture was introduced in Pytest 3.9. Include an explicit definition of that fixture for compatibility with those older Pytest versions. When we're ready to drop support, we can just remove the fixture.We could test this in GitHub Actions but it would be pretty contrived. I think it would be OK to carry this as a compatibility extension without explicitly testing it in CI, but I'm open to hearing differing opinions.