summaryrefslogtreecommitdiffstatshomepage
path: root/tests/basics/fun_globals.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/fun_globals.py')
-rw-r--r--tests/basics/fun_globals.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/basics/fun_globals.py b/tests/basics/fun_globals.py
new file mode 100644
index 0000000000..3f32e8bdb0
--- /dev/null
+++ b/tests/basics/fun_globals.py
@@ -0,0 +1,21 @@
+# test the __globals__ attribute of a function
+
+
+def foo():
+ pass
+
+
+if not hasattr(foo, "__globals__"):
+ print("SKIP")
+ raise SystemExit
+
+print(type(foo.__globals__))
+print(foo.__globals__ is globals())
+
+foo.__globals__["bar"] = 123
+print(bar)
+
+try:
+ foo.__globals__ = None
+except AttributeError:
+ print("AttributeError")