-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Issue 460: Fail on getfuncargvalue(<fixture with params>) #1620
Issue 460: Fail on getfuncargvalue(<fixture with params>) #1620
Conversation
if fixturedef.params is not None: | ||
curdir = py.path.local() | ||
frame = inspect.stack()[3] | ||
_, source_path, source_lineno, _, _, _ = frame |
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.
source-path should be relative to the test root if possible
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.
This seems kind of weird - if I'm reading the docs correctly you can do inspect.getframeinfo(frame)
and then have a namedtuple with filename
and lineno
attributes.
E*Failed: The requested fixture has no parameter defined for the current test. | ||
E* | ||
E*Requested fixture 'fix_with_param' defined in: | ||
E*{}:4 |
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.
This is not valid in py26
, that's why CI failed. 😉
435d68a
to
e5e91af
Compare
Added the commented changes
|
e5e91af
to
5854a71
Compare
LGTM, but I'd rather not be the one deciding on the backwards compatibility break and if it's okay 😆 - as said, I think it's perfectly fine for 3.0. |
Hmm which backward compatibility break? |
The fact that this previously silently failed to apply the params: @pytest.fixture(params=[0, 1, 2])
def fix_with_param(request):
print "I never call request.param"
def test_foo(request):
request.getfuncargvalue('fix_with_param') And now fails with the helpful error message. |
Fix for #460
Raise helpful failure message, when requesting parametrized fixture at runtime, e.g. with
request.getfuncargvalue
.This now fails before getting to
AttributeError: 'SubRequest' object has no attribute 'param'
.BACKWARD INCOMPAT: Previously these params were simply never defined. So a fixture decorated like
@pytest.fixture(params=[0, 1, 2])
only runs once. Now a failure is raised.