-
Notifications
You must be signed in to change notification settings - Fork 222
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
Fix compatibility issues with pytest 8.1 (fixture registration) #680
Conversation
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.
Hey @youtux - I've reviewed your changes and they look great!
General suggestions:
- Consider adding error handling or validation for the inputs of the newly introduced
inject_fixture
function to ensure robustness. - Review the compatibility adjustments to ensure they align with the intended use cases and pytest's expected behavior.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Docstrings: all looks good
Thanks for using Sourcery. We offer it for free for open source projects and would be very grateful if you could help us grow. If you like it, would you consider sharing Sourcery on your favourite social media? ✨
def inject_fixture(request: FixtureRequest, arg: str, value: Any) -> None: | ||
"""Inject fixture into pytest fixture request. | ||
|
||
:param request: pytest fixture request | ||
:param arg: argument name | ||
:param value: argument value | ||
""" | ||
|
||
request._fixturemanager._register_fixture( | ||
name=arg, | ||
func=lambda: value, | ||
nodeid=request.node.nodeid, | ||
) |
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.
suggestion (edge_case_not_handled): The implementation of inject_fixture
for pytest versions >= 8.1 seems to lack error handling or validation for the inputs. Consider adding checks to ensure that the request
, arg
, and value
parameters meet expected conditions or constraints.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #680 +/- ##
==========================================
+ Coverage 95.17% 95.35% +0.17%
==========================================
Files 50 50
Lines 1825 1830 +5
Branches 200 201 +1
==========================================
+ Hits 1737 1745 +8
+ Misses 57 55 -2
+ Partials 31 30 -1 ☔ View full report in Codecov by Sentry. |
Move logic for older pythons in the `compat.py` module.
f8a9ce0
to
b4e13a0
Compare
TODO: