Fix crash that happened under --runxfail -o empty_parameter_set_mark=xfail#7289
Fix crash that happened under --runxfail -o empty_parameter_set_mark=xfail#7289gnikonorov wants to merge 5 commits intopytest-dev:mainfrom
Conversation
|
So now the file in the linked issue would be processed as so: |
This comment has been minimized.
This comment has been minimized.
|
I think this is good to go @RonnyPfannschmidt, barring review |
|
|
||
| def get_direct_param_fixture_func(request): | ||
| return request.param | ||
| return request.param if hasattr(request, "param") else None |
There was a problem hiding this comment.
that change makes the fixture helper incorrect - if no parameter is existing this one has to raise a failure - the tests shouldnt even run however
There was a problem hiding this comment.
Shouldn't this raise an error then, or perhaps pytest.fail("no direct parameter")??
RonnyPfannschmidt
left a comment
There was a problem hiding this comment.
i propose introducing a runnable=True/False extra indication on xfail, so that those that are marked as absolutely not runable can trigger a warning when runxfail is given instead of running and failing
|
Thanks for explaining @RonnyPfannschmidt Just to clarify, you're suggesting that if runnable=True, we just catch the thrown exception and raise a warning instead? As it stands right now, this change will just ignore the empty parameterset and run the test if Here's a run with And, now the empty parameterset values are set to |
|
missing parameter literally means you have nothing to run any test with - running a test with a different value is wrong |
|
Thanks for explaining @RonnyPfannschmidt. Do we want to add a runnable flag to xfail though? To me it seems like the point of runxfail is to force a run so we’d be blocking runxfail. I guess this wasn’t as straight forward as I originally thought |
|
to be fair i would rather not have this type of flag at all, its just one possible solution im not sure what a good option looks like |
|
agreed. In this case the user wouldn’t be able to add the flag since the test is being marked xfail by -o. Unless they added another command line flag for it which seems cumbersome |
We already have the |
The |
|
i just took a quick look at xfail and how it monkeypatches the pytest module, instead of using the direct fixture value function would then be something that raises a error indicating that the test was not given a parameter for the value |
|
that works for me, is everyone else on board? @nicoddemus @bluetech |
I'm probably misunderstanding, but @_with_exception(XFailed)
def xfail(reason: str = "") -> "NoReturn":
...
raise XFailed(reason)And So isn't it the same thing? |
|
I think @RonnyPfannschmidt refers to the nasty hack in skipping.py: pytest/src/_pytest/skipping.py Lines 49 to 61 in d69e9e6 However this hack is not relevant for the xfail mark The skipping code itself checks |
|
Ahh thanks @bluetech that explains it! |
|
can someone explain why we have this hack in the first place? It does seem really dirty |
|
this hack is to prevent the imperative |
|
Thanks for explaining @RonnyPfannschmidt |
|
@gnikonorov - would you still be interested in finishing this up? Otherwise it might be better to close this. |
|
closing for now , happy to reopen when work is resumed |
Closes #4497
Make sure
runxfailplays nicely withempty_parameter_set_mark = xfail