File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -317,6 +317,34 @@ def test_super_init_leaks(self):
317
317
for i in range (1000 ):
318
318
super .__init__ (sp , int , i )
319
319
320
+ def test_replaced_super (self ):
321
+ src = """
322
+ class A:
323
+ def f(self): pass
324
+
325
+ class B(A):
326
+ def f(self): super().f()
327
+ """
328
+ g = {}
329
+ exec (src , g )
330
+
331
+ my_super_called = False
332
+ my_super_f_called = False
333
+
334
+ class MySuper :
335
+ def __init__ (self ):
336
+ nonlocal my_super_called
337
+ my_super_called = True
338
+
339
+ def f (self ):
340
+ nonlocal my_super_f_called
341
+ my_super_f_called = True
342
+
343
+ g ['super' ] = MySuper
344
+ g ['B' ]().f ()
345
+ self .assertTrue (my_super_called )
346
+ self .assertTrue (my_super_f_called )
347
+
320
348
321
349
if __name__ == "__main__" :
322
350
unittest .main ()
You can’t perform that action at this time.
0 commit comments