Change test for exception to use pytest.raises