Skip to content

Commit a4756b0

Browse files
committed
Ensure the order of applying total_ordering does not matter
1 parent 416d88d commit a4756b0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tests/test_make.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,14 +1960,15 @@ class C(object):
19601960
assert 0 == len(recwarn.list)
19611961

19621962
@pytest.mark.parametrize("slots", [True, False])
1963-
def test_total_ordering(self, slots):
1963+
@pytest.mark.parametrize("first", [True, False])
1964+
def test_total_ordering(self, slots, first):
19641965
"""
19651966
functools.total_ordering works as expected if an order method and an eq
19661967
method are detected.
1968+
1969+
Ensure the order doesn't matter.
19671970
"""
19681971

1969-
@attr.s(auto_detect=True, slots=slots)
1970-
@functools.total_ordering
19711972
class C(object):
19721973
x = attr.ib()
19731974
own_eq_called = attr.ib(default=False)
@@ -1981,6 +1982,15 @@ def __le__(self, o):
19811982
self.own_le_called = True
19821983
return self.x <= o.x
19831984

1985+
if first:
1986+
C = functools.total_ordering(
1987+
attr.s(auto_detect=True, slots=slots)(C)
1988+
)
1989+
else:
1990+
C = attr.s(auto_detect=True, slots=slots)(
1991+
functools.total_ordering(C)
1992+
)
1993+
19841994
c1, c2 = C(1), C(2)
19851995

19861996
assert c1 < c2

0 commit comments

Comments
 (0)