PyTest expected exceptions (other exception)
examples/pytest/test_exceptions_failing.py
import pytest def divide(a, b): # if b == 0: # raise ValueError('Cannot divide by Zero') return a / b def test_zero_division(): with pytest.raises(ValueError) as e: divide(1, 0) assert str(e.value) == 'Cannot divide by Zero'