File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -456,6 +456,13 @@ def __str__(self):
456456 def __repr__ (self ):
457457 return f"<{ str (self )} >"
458458
459+ def __bool__ (self ):
460+ """Always evaluate DiffSync instances as True.
461+
462+ This is needed because without it the __len__ method would be used, which in turn would cause empty DiffSync
463+ instances to evaluate as False."""
464+ return True
465+
459466 def __len__ (self ):
460467 """Total number of elements stored."""
461468 return self .store .count ()
Original file line number Diff line number Diff line change @@ -894,3 +894,7 @@ class NoDeleteInterfaceDiffSync(BackendA):
894894 diff = extra_models .diff_from (backend_a )
895895 print (diff .str ()) # for debugging of any failure
896896 assert not diff .has_diffs ()
897+
898+
899+ def test_diffsync_empty_instance_is_truthy ():
900+ assert bool (DiffSync ())
You can’t perform that action at this time.
0 commit comments