diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2010-05-11 11:49:21 +0200 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2010-05-11 11:49:21 +0200 |
commit | 26a215b95153a78caf0ac5aa16d17e1510f52619 (patch) | |
tree | 98f31a26f8611de32a97323e23aa7142cf8f01a5 | |
parent | 44103ba35cc481332d1181cb385048f7d070da8a (diff) | |
download | pylint-git-26a215b95153a78caf0ac5aa16d17e1510f52619.tar.gz |
apply emile's patch, fix test with python>=2.6
-rw-r--r-- | test/input/func_arguments.py | 4 | ||||
-rw-r--r-- | test/input/func_keyword_repeat_py26.py | 11 | ||||
-rw-r--r-- | test/input/func_keyword_repeat_py_26.py | 11 | ||||
-rw-r--r-- | test/messages/func_arguments.txt | 2 | ||||
-rw-r--r-- | test/messages/func_keyword_repeat_py26.txt | 1 | ||||
-rw-r--r-- | test/messages/func_keyword_repeat_py_26.txt | 2 | ||||
-rw-r--r-- | test/test_func.py | 11 |
7 files changed, 34 insertions, 8 deletions
diff --git a/test/input/func_arguments.py b/test/input/func_arguments.py index ce3cc5425..a22ff8e7c 100644 --- a/test/input/func_arguments.py +++ b/test/input/func_arguments.py @@ -25,8 +25,8 @@ function_3_args('bab', 'bebe', None, 5.6) function_default_arg(1, two=5) function_default_arg(two=5) -function_default_arg(two=5, two=7) -function_default_arg(two=5, one=7, one='bob') +# repeated keyword is syntax error in python >= 2.6: +# tests are moved to func_keyword_repeat_py25- / func_keyword_repeat_py26 function_1_arg(bob=4) function_default_arg(1, 4, coin="hello") diff --git a/test/input/func_keyword_repeat_py26.py b/test/input/func_keyword_repeat_py26.py new file mode 100644 index 000000000..eeb733a8e --- /dev/null +++ b/test/input/func_keyword_repeat_py26.py @@ -0,0 +1,11 @@ +"""Test repeated keyword argument checker""" +__revision__ = '' + +def function_default_arg(one=1, two=2): + """fonction with default value""" + return two, one + +function_default_arg(two=5, two=7) +function_default_arg(two=5, one=7, one='bob') + + diff --git a/test/input/func_keyword_repeat_py_26.py b/test/input/func_keyword_repeat_py_26.py new file mode 100644 index 000000000..eeb733a8e --- /dev/null +++ b/test/input/func_keyword_repeat_py_26.py @@ -0,0 +1,11 @@ +"""Test repeated keyword argument checker""" +__revision__ = '' + +def function_default_arg(one=1, two=2): + """fonction with default value""" + return two, one + +function_default_arg(two=5, two=7) +function_default_arg(two=5, one=7, one='bob') + + diff --git a/test/messages/func_arguments.txt b/test/messages/func_arguments.txt index 2596f4ab8..24bbdc44f 100644 --- a/test/messages/func_arguments.txt +++ b/test/messages/func_arguments.txt @@ -5,8 +5,6 @@ E: 22: No value passed for parameter 'first_argument' in function call E: 22: No value passed for parameter 'second_argument' in function call E: 22: No value passed for parameter 'third_argument' in function call E: 24: Too many positional arguments for function call -E: 28: Duplicate keyword argument 'two' in function call -E: 29: Duplicate keyword argument 'one' in function call E: 31: No value passed for parameter 'first_argument' in function call E: 31: Passing unexpected keyword argument 'bob' in function call E: 32: Passing unexpected keyword argument 'coin' in function call diff --git a/test/messages/func_keyword_repeat_py26.txt b/test/messages/func_keyword_repeat_py26.txt new file mode 100644 index 000000000..f2652f034 --- /dev/null +++ b/test/messages/func_keyword_repeat_py26.txt @@ -0,0 +1 @@ +E: 8: keyword argument repeated diff --git a/test/messages/func_keyword_repeat_py_26.txt b/test/messages/func_keyword_repeat_py_26.txt new file mode 100644 index 000000000..b285b97c4 --- /dev/null +++ b/test/messages/func_keyword_repeat_py_26.txt @@ -0,0 +1,2 @@ +E: 8: Duplicate keyword argument 'two' in function call +E: 9: Duplicate keyword argument 'one' in function call diff --git a/test/test_func.py b/test/test_func.py index 2d67824b6..249ca865b 100644 --- a/test/test_func.py +++ b/test/test_func.py @@ -38,8 +38,7 @@ checkers.initialize(linter) linter.global_set_option('required-attributes', ('__revision__',)) PY23 = sys.version_info >= (2, 3) -PY24 = sys.version_info >= (2, 4) -PY25 = sys.version_info >= (2, 5) +PY26 = sys.version_info >= (2, 6) if linesep != '\n': @@ -135,8 +134,8 @@ class TestTests(testlib.TestCase): except ValueError: continue todo.sort() - if PY25: - self.assertEqual(todo, ['E0503', 'I0001']) + if PY26: + self.assertEqual(todo, ['E0503', 'E1122', 'I0001']) elif PY23: self.assertEqual(todo, ['E0503', 'I0001']) else: # python < 2.3 @@ -177,6 +176,10 @@ def make_tests(filter_rgx): if pyrestr.isdigit(): # '24', '25'... if sys.version_info < tuple([int(i) for i in pyrestr]): continue + if pyrestr.startswith('_') and pyrestr[1:].isdigit(): + # skip test for higher python versions + if sys.version_info >= ( int(pyrestr[1]), int(pyrestr[2]) ): + continue if not is_to_run(module_file): continue base = module_file.replace('func_', '').replace('.py', '') |