Skip to content

Commit 22c2fec

Browse files
committed
Add tests for <= >= and check exception is raised for python3.
1 parent 13ec521 commit 22c2fec

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

roundup/anypy/cmp_.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ def __gt__(self, other):
7171

7272

7373
def _test():
74+
import sys
75+
_py3 = sys.version_info[0] > 2
76+
7477
Comp = NoneAndDictComparable
7578

7679
assert Comp(None) < Comp(0)
@@ -82,6 +85,13 @@ def _test():
8285
assert not Comp({}) < Comp(None)
8386
assert not Comp((0, 0)) < Comp((0, None))
8487

88+
try:
89+
not Comp("") < Comp((0, None))
90+
if _py3:
91+
assert False, "Incompatible types are reporting comparable."
92+
except TypeError:
93+
pass
94+
8595
assert Comp((0, 0)) < Comp((0, 0, None))
8696
assert Comp((0, None, None)) < Comp((0, 0, 0))
8797

@@ -90,6 +100,12 @@ def _test():
90100
assert not Comp(1) < Comp(0)
91101
assert not Comp(0) > Comp(0)
92102

103+
104+
assert Comp(0) <= Comp(1)
105+
assert Comp(1) >= Comp(0)
106+
assert not Comp(1) <= Comp(0)
107+
assert Comp(0) >= Comp(0)
108+
93109
assert Comp({0: None}) < Comp({0: 0})
94110
assert Comp({0: 0}) < Comp({0: 1})
95111

0 commit comments

Comments
 (0)