-
Notifications
You must be signed in to change notification settings - Fork 42
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 _after_postgeneration being invoked twice #164
Conversation
"""Get the local namespace of the caller frame.""" | ||
return sys._getframe(depth).f_locals | ||
return sys._getframe(depth + 2).f_locals |
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.
why this change is required?
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.
not needed, but it makes more sense, so that the caller can specify if it wants the locals from the caller (from its POV) or levels from its POV
@@ -291,6 +291,24 @@ def evaluate(request: SubRequest, value: LazyFixture[T] | T) -> T: | |||
return value.evaluate(request) if isinstance(value, LazyFixture) else value | |||
|
|||
|
|||
def noop(*args: Any, **kwargs: Any) -> None: | |||
"""No-op function.""" | |||
pass |
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.
NIP: pass
is not required when docstring is provided
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.
ah yeah true that
|
||
def test_postgeneration_called_once(self, request): | ||
"""Test that ``_after_postgeneration`` is called only once.""" | ||
foo = request.getfixturevalue("collector") |
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.
why not add collector
as a test's function argument to let pytest
do the job of getting the fixture value?
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.
it's just in case there is an error in the setup, it's nicer to have the tests error out at runtime, rather than at collection time (especially if doing TDD), as it would prevent you from running other tests
Partially fixes #156.