Pytest xfail: Mark a Test as Expected to Fail

Pytest xfail: Mark a Test as Expected to Fail

If you expect a test to fail, use pytest xfail marker. This will prevent pytest from marking a test as failed when there is an exception.

To be more specific about what exception you expect to see, use the raises argument.

My previous tips on testing.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran