None
should be expr is None
516
517 stream = VideoStream.query.get(stream.id)
518
519 assert stream == None520
521
522def test_edit_stream_user_error(db, client, jwt):
None
should be expr is None
500
501 stream = VideoStream.query.get(stream.id)
502
503 assert stream == None504
505
506def test_delete_stream_event_organizer(db, client, user, jwt):
None
should be expr is None
215
216 stream = VideoStream.query.get(stream.id)
217
218 assert stream == None219
220
221def test_edit_stream_organizer(db, client, user, jwt):
None
should be expr is None
57 attendee_id = attendee.id
58 delete_ticket_holders_no_order_id()
59 ticket_holder = TicketHolder.query.get(attendee_id)
60 assert ticket_holder == None 61
62
63def test_send_monthly_invoice(db):
None
should be expr is not None
47 attendee_id = attendee.id
48 delete_ticket_holders_no_order_id()
49 ticket_holder = TicketHolder.query.get(attendee_id)
50 assert ticket_holder != None 51
52
53def test_delete_ticket_holders_with_no_order_id(db):
Comparisons to the singleton objects, like True
, False
, and None
, should be done with identity, not equality. Use is
or is not
.
Identity checks are faster than equality checks.
Also, the equality checks can result in unintended behaviour in some cases:
>>> 1 is True
False
>>> 1 == True
True
>>> 1.0 is True
False
>>> 1.0 == True
True
value = fx()
if value == True: # `==` can cause unintended behaviour
print(value)
if value != None:
print(value)
value = fx()
if value is True: # `is` for Identity comparison
print(value)
if value is not None:
print(value)
Equality comparisons might be required in some cases, especially in SQLAlchemy, SQLObject, ORMs, etc. In these cases, it is safe to ignore this issue.