summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorsten Marek <shlomme@gmail.com>2014-07-25 15:32:17 +0200
committerTorsten Marek <shlomme@gmail.com>2014-07-25 15:32:17 +0200
commita288c6eceb47bca013b9c9ebf0c37e3260303654 (patch)
tree61c182aae3c4f487e4e25c8e846a1b649ab93e00
parentabdb701148386536b3af783056045550bd6a97a3 (diff)
downloadpylint-a288c6eceb47bca013b9c9ebf0c37e3260303654.tar.gz
Porting tests over to the new framework.
-rw-r--r--test/functional/bad_continuation.py (renamed from test/input/func_bad_continuation.py)6
-rw-r--r--test/functional/bad_continuation.txt63
-rw-r--r--test/functional/exception_is_binary_op.py12
-rw-r--r--test/functional/exception_is_binary_op.txt4
-rw-r--r--test/functional/redefined_builtin.py9
-rw-r--r--test/functional/redefined_builtin.txt2
-rw-r--r--test/functional/useless_else_on_loop.py (renamed from test/input/func_useless_else_on_loop.py)10
-rw-r--r--test/functional/useless_else_on_loop.txt5
-rw-r--r--test/input/func_w0622.py11
-rw-r--r--test/input/func_w0711.py15
-rw-r--r--test/messages/func_bad_continuation.txt64
-rw-r--r--test/messages/func_useless_else_on_loop.txt5
-rw-r--r--test/messages/func_w0711.txt4
-rw-r--r--test/test_func.py3
14 files changed, 104 insertions, 109 deletions
diff --git a/test/input/func_bad_continuation.py b/test/functional/bad_continuation.py
index f303915..3d62521 100644
--- a/test/input/func_bad_continuation.py
+++ b/test/functional/bad_continuation.py
@@ -1,7 +1,5 @@
"""Regression test case for bad-continuation."""
-__revision__ = 1
-
# Various alignment for brackets
LIST0 = [
1, 2, 3
@@ -39,7 +37,7 @@ W2 = ['some', 'contents' # with a continued comment that may be aligned
'and',
'more', # but this
# [bad-continuation] is not accepted
- 'contents', # nor this. [bad-continuation]
+ 'contents', # [bad-continuation] nor this.
]
# Values in dictionaries should be indented 4 spaces further if they are on a
@@ -108,7 +106,7 @@ def continue3(
"""A function with misaligned arguments"""
print some_arg, some_other_arg
-def continue4(
+def continue4( # pylint:disable=missing-docstring
arg1,
arg2): print arg1, arg2
diff --git a/test/functional/bad_continuation.txt b/test/functional/bad_continuation.txt
new file mode 100644
index 0000000..732858e
--- /dev/null
+++ b/test/functional/bad_continuation.txt
@@ -0,0 +1,63 @@
+bad-continuation:12::Wrong hanging indentation.
+ ] # [bad-continuation]
+| ^|
+bad-continuation:17::Wrong continued indentation.
+ 7, # [bad-continuation]
+ | ^
+bad-continuation:25::Wrong hanging indentation.
+ 'b': 2, # [bad-continuation]
+ ^|
+bad-continuation:31::Wrong hanging indentation.
+ 'b': 2, # [bad-continuation]
+ ^|
+bad-continuation:39::Wrong continued indentation.
+ # [bad-continuation] is not accepted
+ | | ^
+bad-continuation:40::Wrong continued indentation.
+ 'contents', # [bad-continuation] nor this.
+ | ^
+bad-continuation:49::Wrong hanging indentation in dict value.
+ 'value2', # [bad-continuation]
+ | ^ |
+bad-continuation:59::Wrong continued indentation.
+ 'wrong', # [bad-continuation]
+ ^ |
+bad-continuation:83::Wrong hanging indentation in dict value.
+'value1', # [bad-continuation]
+^ | |
+bad-continuation:87::Wrong hanging indentation in dict value.
+ 'value1', # [bad-continuation]
+ ^ | |
+bad-continuation:104::Wrong hanging indentation before block.
+ some_arg, # [bad-continuation]
+ ^ |
+bad-continuation:105::Wrong hanging indentation before block.
+ some_other_arg): # [bad-continuation]
+ ^ |
+bad-continuation:125::Wrong continued indentation.
+ "b") # [bad-continuation]
+ ^ |
+bad-continuation:139::Wrong hanging indentation before block.
+ ): pass # [bad-continuation]
+| ^|
+bad-continuation:142::Wrong continued indentation before block.
+ 2): # [bad-continuation]
+ ^ |
+bad-continuation:150::Wrong continued indentation.
+ 2 and # [bad-continuation]
+ | ^
+bad-continuation:155::Wrong hanging indentation before block.
+ 2): pass # [bad-continuation]
+ ^ | |
+bad-continuation:162::Wrong continued indentation before block.
+ 2 or # [bad-continuation]
+ |^ |
+bad-continuation:166::Wrong continued indentation before block.
+ 2): pass # [bad-continuation]
+ ^ | |
+bad-continuation:172::Wrong hanging indentation before block.
+ 2): # [bad-continuation]
+ ^ | |
+bad-continuation:183::Wrong continued indentation.
+ 2): # [bad-continuation]
+ ^ |
diff --git a/test/functional/exception_is_binary_op.py b/test/functional/exception_is_binary_op.py
new file mode 100644
index 0000000..443a478
--- /dev/null
+++ b/test/functional/exception_is_binary_op.py
@@ -0,0 +1,12 @@
+"""Warn about binary operations used as exceptions."""
+
+try:
+ pass
+except Exception or StandardError: # [binary-op-exception]
+ print "caught1"
+except Exception and StandardError: # [binary-op-exception]
+ print "caught2"
+except Exception or StandardError: # [binary-op-exception]
+ print "caught3"
+except (Exception or StandardError), exc: # [binary-op-exception]
+ print "caught4"
diff --git a/test/functional/exception_is_binary_op.txt b/test/functional/exception_is_binary_op.txt
new file mode 100644
index 0000000..039bc3f
--- /dev/null
+++ b/test/functional/exception_is_binary_op.txt
@@ -0,0 +1,4 @@
+binary-op-exception:5::Exception to catch is the result of a binary "or" operation
+binary-op-exception:7::Exception to catch is the result of a binary "and" operation
+binary-op-exception:9::Exception to catch is the result of a binary "or" operation
+binary-op-exception:11::Exception to catch is the result of a binary "or" operation
diff --git a/test/functional/redefined_builtin.py b/test/functional/redefined_builtin.py
new file mode 100644
index 0000000..ace2ea6
--- /dev/null
+++ b/test/functional/redefined_builtin.py
@@ -0,0 +1,9 @@
+"""Tests for redefining builtins."""
+
+def function():
+ """Redefined local."""
+ type = 1 # [redefined-builtin]
+ print type
+
+# pylint:disable=invalid-name
+map = {} # [redefined-builtin]
diff --git a/test/functional/redefined_builtin.txt b/test/functional/redefined_builtin.txt
new file mode 100644
index 0000000..71518ce
--- /dev/null
+++ b/test/functional/redefined_builtin.txt
@@ -0,0 +1,2 @@
+redefined-builtin:5:function:Redefining built-in 'type'
+redefined-builtin:9::Redefining built-in 'map'
diff --git a/test/input/func_useless_else_on_loop.py b/test/functional/useless_else_on_loop.py
index 289366a..4f27cf7 100644
--- a/test/input/func_useless_else_on_loop.py
+++ b/test/functional/useless_else_on_loop.py
@@ -7,14 +7,14 @@ def test_return_for():
for i in range(10):
if i % 2:
return i
- else:
+ else: # [useless-else-on-loop]
print 'math is broken'
def test_return_while():
"""else + return is not accetable."""
while True:
return 1
- else:
+ else: # [useless-else-on-loop]
print 'math is broken'
@@ -23,19 +23,19 @@ while True:
"""A function with a loop."""
for _ in range(10):
break
-else:
+else: # [useless-else-on-loop]
print 'or else!'
while True:
while False:
break
-else:
+else: # [useless-else-on-loop]
print 'or else!'
for j in range(10):
pass
-else:
+else: # [useless-else-on-loop]
print 'fat chance'
for j in range(10):
break
diff --git a/test/functional/useless_else_on_loop.txt b/test/functional/useless_else_on_loop.txt
new file mode 100644
index 0000000..93309b6
--- /dev/null
+++ b/test/functional/useless_else_on_loop.txt
@@ -0,0 +1,5 @@
+useless-else-on-loop:10:test_return_for:Else clause on loop without a break statement
+useless-else-on-loop:17:test_return_while:Else clause on loop without a break statement
+useless-else-on-loop:26::Else clause on loop without a break statement
+useless-else-on-loop:33::Else clause on loop without a break statement
+useless-else-on-loop:38::Else clause on loop without a break statement
diff --git a/test/input/func_w0622.py b/test/input/func_w0622.py
deleted file mode 100644
index 5769841..0000000
--- a/test/input/func_w0622.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# pylint: disable=C0103
-"""test built-in redefinition
-"""
-__revision__ = 0
-
-def function():
- """yo"""
- type = 1
- print type
-
-map = {}
diff --git a/test/input/func_w0711.py b/test/input/func_w0711.py
deleted file mode 100644
index 97c3697..0000000
--- a/test/input/func_w0711.py
+++ /dev/null
@@ -1,15 +0,0 @@
-"""find binary operations used as exceptions
-"""
-
-__revision__ = 1
-
-try:
- __revision__ += 1
-except Exception or StandardError:
- print "caught1"
-except Exception and StandardError:
- print "caught2"
-except Exception or StandardError:
- print "caught3"
-except (Exception or StandardError), exc:
- print "caught4"
diff --git a/test/messages/func_bad_continuation.txt b/test/messages/func_bad_continuation.txt
deleted file mode 100644
index 42087e5..0000000
--- a/test/messages/func_bad_continuation.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-C: 14: Wrong hanging indentation.
- ] # [bad-continuation]
-| ^|
-C: 19: Wrong continued indentation.
- 7, # [bad-continuation]
- | ^
-C: 27: Wrong hanging indentation.
- 'b': 2, # [bad-continuation]
- ^|
-C: 33: Wrong hanging indentation.
- 'b': 2, # [bad-continuation]
- ^|
-C: 41: Wrong continued indentation.
- # [bad-continuation] is not accepted
- | | ^
-C: 42: Wrong continued indentation.
- 'contents', # nor this. [bad-continuation]
- | ^
-C: 51: Wrong hanging indentation in dict value.
- 'value2', # [bad-continuation]
- | ^ |
-C: 61: Wrong continued indentation.
- 'wrong', # [bad-continuation]
- ^ |
-C: 85: Wrong hanging indentation in dict value.
-'value1', # [bad-continuation]
-^ | |
-C: 89: Wrong hanging indentation in dict value.
- 'value1', # [bad-continuation]
- ^ | |
-C:106: Wrong hanging indentation before block.
- some_arg, # [bad-continuation]
- ^ |
-C:107: Wrong hanging indentation before block.
- some_other_arg): # [bad-continuation]
- ^ |
-C:111:continue4: Missing function docstring
-C:127: Wrong continued indentation.
- "b") # [bad-continuation]
- ^ |
-C:141: Wrong hanging indentation before block.
- ): pass # [bad-continuation]
-| ^|
-C:144: Wrong continued indentation before block.
- 2): # [bad-continuation]
- ^ |
-C:152: Wrong continued indentation.
- 2 and # [bad-continuation]
- | ^
-C:157: Wrong hanging indentation before block.
- 2): pass # [bad-continuation]
- ^ | |
-C:164: Wrong continued indentation before block.
- 2 or # [bad-continuation]
- |^ |
-C:168: Wrong continued indentation before block.
- 2): pass # [bad-continuation]
- ^ | |
-C:174: Wrong hanging indentation before block.
- 2): # [bad-continuation]
- ^ | |
-C:185: Wrong continued indentation.
- 2): # [bad-continuation]
- ^ |
diff --git a/test/messages/func_useless_else_on_loop.txt b/test/messages/func_useless_else_on_loop.txt
deleted file mode 100644
index 6c2c60c..0000000
--- a/test/messages/func_useless_else_on_loop.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-W: 10:test_return_for: Else clause on loop without a break statement
-W: 17:test_return_while: Else clause on loop without a break statement
-W: 26: Else clause on loop without a break statement
-W: 33: Else clause on loop without a break statement
-W: 38: Else clause on loop without a break statement
diff --git a/test/messages/func_w0711.txt b/test/messages/func_w0711.txt
deleted file mode 100644
index a158818..0000000
--- a/test/messages/func_w0711.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-W: 8: Exception to catch is the result of a binary "or" operation
-W: 10: Exception to catch is the result of a binary "and" operation
-W: 12: Exception to catch is the result of a binary "or" operation
-W: 14: Exception to catch is the result of a binary "or" operation
diff --git a/test/test_func.py b/test/test_func.py
index 8a0d983..c6394a1 100644
--- a/test/test_func.py
+++ b/test/test_func.py
@@ -44,7 +44,8 @@ class LintTestNonExistentModuleTC(LintTestUsingModule):
class TestTests(testlib.TestCase):
"""check that all testable messages have been checked"""
- PORTED = set(['I0001', 'I0010', 'W0712', 'E1001', 'W1402', 'E1310', 'E0202'])
+ PORTED = set(['I0001', 'I0010', 'W0712', 'E1001', 'W1402', 'E1310', 'E0202',
+ 'W0711'])
@testlib.tag('coverage')
def test_exhaustivity(self):