You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Car(db.Entity):
colour = Required(str)
def before_insert(self):
if self.colour != 'black':
raise IntegrityError("You can choose any colour, as long as it's black.")
My test looks like this:
def test_create_car():
with pytest.raises(IntegrityError) as exc_info:
with db_session:
Car(colour="pink")
assert exc_info.value == "You can choose any colour, as long as it's black."
I'm having trouble finding out how I can check the error message attached to the captured IntegrityError. exc_info.value is an empty string.
The text was updated successfully, but these errors were encountered:
Suppose I have this model:
My test looks like this:
I'm having trouble finding out how I can check the error message attached to the captured IntegrityError.
exc_info.value
is an empty string.The text was updated successfully, but these errors were encountered: