mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Use is for bool comparison
This commit is contained in:
@@ -14,12 +14,12 @@ assert not 0.0
|
||||
|
||||
assert not None
|
||||
|
||||
assert bool() == False
|
||||
assert bool(1) == True
|
||||
assert bool({}) == False
|
||||
assert bool() is False
|
||||
assert bool(1) is True
|
||||
assert bool({}) is False
|
||||
|
||||
assert bool(NotImplemented) == True
|
||||
assert bool(...) == True
|
||||
assert bool(NotImplemented) is True
|
||||
assert bool(...) is True
|
||||
|
||||
if not 1:
|
||||
raise BaseException
|
||||
@@ -105,8 +105,8 @@ class TestMagicMethodLenOne:
|
||||
return 1
|
||||
|
||||
|
||||
assert bool(TestMagicMethodLenZero()) == False
|
||||
assert bool(TestMagicMethodLenOne()) == True
|
||||
assert bool(TestMagicMethodLenZero()) is False
|
||||
assert bool(TestMagicMethodLenOne()) is True
|
||||
|
||||
|
||||
# check __len__ and __bool__
|
||||
|
||||
@@ -23,12 +23,12 @@ assert int("101", base=2) == 5
|
||||
|
||||
# magic methods should only be implemented for other ints
|
||||
|
||||
assert (1).__eq__(1) == True
|
||||
assert (1).__ne__(1) == False
|
||||
assert (1).__gt__(1) == False
|
||||
assert (1).__ge__(1) == True
|
||||
assert (1).__lt__(1) == False
|
||||
assert (1).__le__(1) == True
|
||||
assert (1).__eq__(1) is True
|
||||
assert (1).__ne__(1) is False
|
||||
assert (1).__gt__(1) is False
|
||||
assert (1).__ge__(1) is True
|
||||
assert (1).__lt__(1) is False
|
||||
assert (1).__le__(1) is True
|
||||
assert (1).__add__(1) == 2
|
||||
assert (1).__radd__(1) == 2
|
||||
assert (2).__sub__(1) == 1
|
||||
|
||||
Reference in New Issue
Block a user