Skip to content

Commit 0b05129

Browse files
committed
Adjust test
1 parent 5db80c3 commit 0b05129

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

tests/test_method.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,7 @@ def test_method_with_pointer_array_argument():
12591259

12601260
def test_method_call_implicit_conversion():
12611261

1262-
class Answer:
1262+
class IntAnswerMixin:
12631263
# For Python >= 3.8
12641264
def __index__(self):
12651265
return 42
@@ -1268,7 +1268,10 @@ def __index__(self):
12681268
def __int__(self):
12691269
return 42
12701270

1271-
class FloatAnswer(Answer):
1271+
class Answer(int, IntAnswerMixin):
1272+
pass
1273+
1274+
class FloatAnswer(float, IntAnswerMixin):
12721275
def __float__(self):
12731276
return 42.0
12741277

@@ -1281,3 +1284,13 @@ def __float__(self):
12811284
compare_to = min_value.CompareTo.__overloads__[t]
12821285

12831286
assert compare_to(v) == -1
1287+
1288+
class SomeNonFloat:
1289+
def __float__(self):
1290+
return 42.0
1291+
1292+
for t in [System.Double, System.Single]:
1293+
with pytest.raises(TypeError):
1294+
min_value = t(t.MinValue)
1295+
compare_to = min_value.CompareTo.__overloads__[t]
1296+
assert compare_to(SomeNonFloat()) == -1

0 commit comments

Comments
 (0)