Skip to content

Commit 84519e0

Browse files
committed
tests/basics/class_del: Test class mutation scenarios.
Signed-off-by: Anson Mansfield <amansfield@mantaro.com>
1 parent 2036c1c commit 84519e0

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed
File renamed without changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import gc
3+
4+
5+
class Foo:
6+
pass
7+
8+
9+
def del_function(self):
10+
print("__del__")
11+
12+
13+
f = Foo()
14+
try:
15+
Foo.__del__ = del_function
16+
except AttributeError:
17+
print("AttributeError")
18+
del f
19+
20+
gc.collect()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AttributeError

tests/basics/class_del_postadded.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
import gc
3+
4+
5+
class Foo:
6+
pass
7+
8+
9+
def del_function(self):
10+
print("__del__")
11+
12+
13+
Foo.__del__ = del_function
14+
f = Foo()
15+
del f
16+
17+
gc.collect()

0 commit comments

Comments
 (0)