summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcpopa <devnull@localhost>2014-07-29 23:03:08 +0300
committercpopa <devnull@localhost>2014-07-29 23:03:08 +0300
commit04c913189440771f075fce0e1f236069e3035117 (patch)
treeb428545f9c89b24cb1e19b9f9b0e4007f65deef6 /test
parentda03d60582b624729f578f0b6dfa0c2c08184c7f (diff)
downloadpylint-04c913189440771f075fce0e1f236069e3035117.tar.gz
Proper handle class level scope for lambdas.
Diffstat (limited to 'test')
-rw-r--r--test/functional/class_scope.py22
-rw-r--r--test/functional/class_scope.txt4
-rw-r--r--test/input/func_scope_regrtest.py15
-rw-r--r--test/messages/func_scope_regrtest.txt2
4 files changed, 26 insertions, 17 deletions
diff --git a/test/functional/class_scope.py b/test/functional/class_scope.py
new file mode 100644
index 0000000..68956c6
--- /dev/null
+++ b/test/functional/class_scope.py
@@ -0,0 +1,22 @@
+# pylint: disable=R0903,W0232
+"""check for scope problems"""
+
+__revision__ = None
+
+class Well(object):
+ """well"""
+ attr = 42
+ get_attr = lambda arg=attr: arg * 24
+ # +1: [used-before-assignment]
+ get_attr_bad = lambda arg=revattr: revattr * 42
+ revattr = 24
+ bad_lambda = lambda: get_attr_bad # [undefined-variable]
+
+ class Data(object):
+ """base hidden class"""
+ class Sub(Data): # [undefined-variable
+ """whaou, is Data found???"""
+ attr = Data() # [undefined-variable]
+ def func(self):
+ """check Sub is not defined here"""
+ return Sub(), self # [undefined-variable]
diff --git a/test/functional/class_scope.txt b/test/functional/class_scope.txt
new file mode 100644
index 0000000..ea6c45a
--- /dev/null
+++ b/test/functional/class_scope.txt
@@ -0,0 +1,4 @@
+used-before-assignment:11:Well.<lambda>:Using variable 'revattr' before assignment
+undefined-variable:13:Well.<lambda>:Undefined variable 'get_attr_bad'
+undefined-variable:19:Well.Sub:Undefined variable 'Data'
+undefined-variable:22:Well.func:Undefined variable 'Sub'
diff --git a/test/input/func_scope_regrtest.py b/test/input/func_scope_regrtest.py
deleted file mode 100644
index 5763397..0000000
--- a/test/input/func_scope_regrtest.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# pylint: disable=R0903,W0232
-"""check for scope problems"""
-
-__revision__ = None
-
-class Well(object):
- """well"""
- class Data(object):
- """base hidden class"""
- class Sub(Data):
- """whaou, is Data found???"""
- attr = Data()
- def func(self):
- """check Sub is not defined here"""
- return Sub(), self
diff --git a/test/messages/func_scope_regrtest.txt b/test/messages/func_scope_regrtest.txt
deleted file mode 100644
index 27ae207..0000000
--- a/test/messages/func_scope_regrtest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-E: 12:Well.Sub: Undefined variable 'Data'
-E: 15:Well.func: Undefined variable 'Sub'