File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -1960,14 +1960,15 @@ class C(object):
1960
1960
assert 0 == len (recwarn .list )
1961
1961
1962
1962
@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 ):
1964
1965
"""
1965
1966
functools.total_ordering works as expected if an order method and an eq
1966
1967
method are detected.
1968
+
1969
+ Ensure the order doesn't matter.
1967
1970
"""
1968
1971
1969
- @attr .s (auto_detect = True , slots = slots )
1970
- @functools .total_ordering
1971
1972
class C (object ):
1972
1973
x = attr .ib ()
1973
1974
own_eq_called = attr .ib (default = False )
@@ -1981,6 +1982,15 @@ def __le__(self, o):
1981
1982
self .own_le_called = True
1982
1983
return self .x <= o .x
1983
1984
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
+
1984
1994
c1 , c2 = C (1 ), C (2 )
1985
1995
1986
1996
assert c1 < c2
You can’t perform that action at this time.
0 commit comments