Skip to content
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

Merged
merged 5 commits into from
Mar 17, 2024

Conversation

youtux
Copy link
Contributor

@youtux youtux commented Mar 13, 2024

TODO:

  • Add changelog entry

Copy link

@sourcery-ai sourcery-ai bot left a 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? ✨

Share Sourcery

Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines +20 to +32
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,
)
Copy link

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.

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

Attention: Patch coverage is 96.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 95.35%. Comparing base (669492d) to head (b4e13a0).

❗ Current head b4e13a0 differs from pull request most recent head ee05bc6. Consider uploading reports for the commit ee05bc6 to get more accurate results

Files Patch % Lines
src/pytest_bdd/compat.py 95.23% 0 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

@youtux youtux changed the title Fix compatibility issues with pytest 8.1 Fix compatibility issues with pytest 8.1 (fixture registration) Mar 17, 2024
@youtux youtux merged commit 1c71bf9 into master Mar 17, 2024
11 checks passed
@youtux youtux deleted the ab/fix-pytest-8.1 branch March 17, 2024 19:18
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