-
Notifications
You must be signed in to change notification settings - Fork 1
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
Recommend to use the name argument in the pytest.fixture decorator #55
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.
Thanks for putting this together!
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.
LGTM!
Can you add a description to the PR, I know the title is self explaining, but let's be consistent in adding descriptions |
I have the filling that this convention could be wider, or more generic. What will happen if we have the following: @pytest.fixture
def app():
yield "app" test_charm.py @pytest.fixture(name="app")
def app_fixture(ops_test):
yield ops_test.model.app
def test_charm(app): None
... |
Added, thanks! |
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.
LGTM
I actually view this PR as a recommendation or tip, the original form of fixture still have its benefit of being short and easy to write. In terms of two fixtures have the same name, pytest will choice one without raising an error. This is a known issue in pytest. pytest-dev/pytest#3966 |
I'm with Weii here, this standard is more to prevent needing to have clashing names with function and arguments which is a bit messy in Python. When there is no clash, |
Ok 👌 |
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.
LGTM
Add a tip about using the
name
argument in thepytest.fixture
decorator to avoid naming conflicts.