pytest-check icon indicating copy to clipboard operation
pytest-check copied to clipboard

Is the 'raises' parameter in xfail ignored?

Open doomofart opened this issue 2 years ago • 1 comments

Hi!

My test returns xfail, although the exception type is not that I specify in 'raises'.

e. g.

@pytest.mark.xfail(raises=ZeroDivisionError)
    def test_xfail(self):
        with check:
            assert 1 == 2

I am waiting 'failed', but the test returns 'xfailed'. I think I'm doing something wrong. Is there another way?

doomofart avatar Oct 19 '23 09:10 doomofart

Looks like we don't support raises yet. Too bad though. It'd be nice to support that.

This could be considered an enhancement, but I realize it's unexpected behavior for you, so bug is also reasonable.

Adding some notes here, so I don't forget.

Perhaps we could interrogate the xfail args, like https://github.com/pytest-dev/pytest/blob/8fb7e8b31efaa55e760c142e26eb82b42081ca28/src/_pytest/skipping.py#L207

I'm hoping it's not too late to deal with the issue in make_report, here https://github.com/okken/pytest-check/blob/61412e6ff96e74b9c8ed2b637a8441e0e35d9f5d/src/pytest_check/plugin.py#L11

okken avatar Oct 31 '23 15:10 okken