with pytest.raises(YourExpectedException):
        # code that raises exception