summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/del_attr.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/del_attr.py')
-rw-r--r--tests/basics/del_attr.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/basics/del_attr.py b/tests/basics/del_attr.py
new file mode 100644
index 0000000000..bec7afb848
--- /dev/null
+++ b/tests/basics/del_attr.py
@@ -0,0 +1,32 @@
+class C:
+ def f():
+ pass
+
+# del a class attribute
+
+del C.f
+try:
+ print(C.x)
+except AttributeError:
+ print("AttributeError")
+try:
+ del C.f
+except AttributeError:
+ print("AttributeError")
+
+# del an instance attribute
+
+c = C()
+
+c.x = 1
+print(c.x)
+
+del c.x
+try:
+ print(c.x)
+except AttributeError:
+ print("AttributeError")
+try:
+ del c.x
+except AttributeError:
+ print("AttributeError")