Skip to content

Commit c50d344

Browse files
committed
Test instance validity in bound method tests
1 parent 3e33040 commit c50d344

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Lib/test/test_functools.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,19 +2918,24 @@ def wrapper(*args, **kwargs):
29182918
return _(*args, **kwargs)
29192919

29202920
class SomeClass:
2921-
def for_dict(self, arg: dict):
2921+
def for_dict(this, arg: dict):
2922+
self.assertIs(this, inst1)
29222923
return "dict"
29232924

2924-
def for_set(self, arg: set, arg2: None):
2925+
def for_set(this, arg: set, arg2: None):
2926+
self.assertIs(this, inst1)
29252927
return "set"
29262928

2927-
def for_complex(self: object, arg: complex, arg2: None):
2929+
def for_complex(this: object, arg: complex, arg2: None):
2930+
self.assertIs(this, inst2)
29282931
return "complex"
29292932

2930-
inst = SomeClass()
2931-
t.register(inst.for_dict)
2932-
t.register(inst.for_set)
2933-
t.register(inst.for_complex)
2933+
inst1 = SomeClass()
2934+
t.register(inst1.for_dict)
2935+
t.register(inst1.for_set)
2936+
2937+
inst2 = SomeClass()
2938+
t.register(inst2.for_complex)
29342939

29352940
self.assertEqual(t(0), "int")
29362941
self.assertEqual(t(''), "str")

0 commit comments

Comments
 (0)