summaryrefslogtreecommitdiff
path: root/test/input/func_globals.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/input/func_globals.py')
-rw-r--r--test/input/func_globals.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/input/func_globals.py b/test/input/func_globals.py
new file mode 100644
index 000000000..f7e6c6536
--- /dev/null
+++ b/test/input/func_globals.py
@@ -0,0 +1,40 @@
+"""
+'W0601': ('global variable %s undefined at the module level',
+ 'Used when a variable is defined through the "global" statement \
+ but the variable is not defined in the module scope.'),
+'W0602': ('Using global for %s but no assigment is done',
+ 'Used when a variable is defined through the "global" statement \
+ but no assigment to this variable is done.'),
+'W0603': ('Using the global statement', # W0121
+ 'Used when you use the "global" statement to update a global \
+ variable. PyLint just try to discourage this \
+ usage. That doesn\'t mean you can not use it !'),
+'W0604': ('Using the global statement at the module level', # W0103
+ 'Used when you use the "global" statement at the module level \
+ since it has no effect'),
+"""
+
+__revision__ = ''
+
+CONSTANT = 1
+
+def fix_contant(value):
+ """all this is ok, but try not using global ;)"""
+ global CONSTANT
+ print CONSTANT
+ CONSTANT = value
+global CSTE # useless
+print CSTE # ko
+
+def other():
+ """global behaviour test"""
+ global HOP
+ print HOP # ko
+
+other()
+
+
+def define_constant():
+ """ok but somevar is not defined at the module scope"""
+ global somevar
+ somevar = 2