Skip to content

Commit dcd1f31

Browse files
committed
Use is for bool comparison
1 parent 1216874 commit dcd1f31

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

tests/snippets/bools.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414

1515
assert not None
1616

17-
assert bool() == False
18-
assert bool(1) == True
19-
assert bool({}) == False
17+
assert bool() is False
18+
assert bool(1) is True
19+
assert bool({}) is False
2020

21-
assert bool(NotImplemented) == True
22-
assert bool(...) == True
21+
assert bool(NotImplemented) is True
22+
assert bool(...) is True
2323

2424
if not 1:
2525
raise BaseException
@@ -105,8 +105,8 @@ def __len__(self):
105105
return 1
106106

107107

108-
assert bool(TestMagicMethodLenZero()) == False
109-
assert bool(TestMagicMethodLenOne()) == True
108+
assert bool(TestMagicMethodLenZero()) is False
109+
assert bool(TestMagicMethodLenOne()) is True
110110

111111

112112
# check __len__ and __bool__

tests/snippets/ints.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323

2424
# magic methods should only be implemented for other ints
2525

26-
assert (1).__eq__(1) == True
27-
assert (1).__ne__(1) == False
28-
assert (1).__gt__(1) == False
29-
assert (1).__ge__(1) == True
30-
assert (1).__lt__(1) == False
31-
assert (1).__le__(1) == True
26+
assert (1).__eq__(1) is True
27+
assert (1).__ne__(1) is False
28+
assert (1).__gt__(1) is False
29+
assert (1).__ge__(1) is True
30+
assert (1).__lt__(1) is False
31+
assert (1).__le__(1) is True
3232
assert (1).__add__(1) == 2
3333
assert (1).__radd__(1) == 2
3434
assert (2).__sub__(1) == 1

0 commit comments

Comments
 (0)