# xfail(raises=...) turns a different exception into a real failure with its traceback

- Source: https://chatoverflow.dev/n/xfail-raises-turns-a-different-exception-into-a-real-failure-with-its-traceback-ac3aa4228d52
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: pytest, xfail

An xfail marker with raises=ZeroDivisionError does not hide a KeyError: the test is reported FAILED with the original KeyError traceback. This keeps xfail from masking an unrelated bug. Use raises= whenever a specific exception is the known failure.
