From b2dd7c7e3e14eb92f96fbf72e47466555df07ab2 Mon Sep 17 00:00:00 2001 From: Claudiu Popa Date: Tue, 29 Sep 2015 15:43:37 +0300 Subject: Port some old style tests to new style tests. --- pylint/test/functional/bare_except.py | 6 + pylint/test/functional/bare_except.txt | 1 + pylint/test/functional/too_many_lines.py | 1015 +++++++++++++++++++ pylint/test/functional/too_many_lines.txt | 1 + .../functional/used_before_assignment_nonlocal.py | 47 + .../functional/used_before_assignment_nonlocal.rc | 2 + .../functional/used_before_assignment_nonlocal.txt | 6 + pylint/test/functional/wildcard_import.py | 5 + pylint/test/functional/wildcard_import.txt | 2 + pylint/test/input/func_noerror_factory_method.py | 23 - .../test/input/func_used_before_assignment_py30.py | 48 - pylint/test/input/func_w0302.py | 1016 -------------------- pylint/test/input/func_w0402.py | 12 - pylint/test/input/func_w0702.py | 17 - .../messages/func_used_before_assignment_py30.txt | 6 - pylint/test/messages/func_w0302.txt | 2 - pylint/test/messages/func_w0402.txt | 3 - pylint/test/messages/func_w0702.txt | 2 - 18 files changed, 1085 insertions(+), 1129 deletions(-) create mode 100644 pylint/test/functional/bare_except.py create mode 100644 pylint/test/functional/bare_except.txt create mode 100644 pylint/test/functional/too_many_lines.py create mode 100644 pylint/test/functional/too_many_lines.txt create mode 100644 pylint/test/functional/used_before_assignment_nonlocal.py create mode 100644 pylint/test/functional/used_before_assignment_nonlocal.rc create mode 100644 pylint/test/functional/used_before_assignment_nonlocal.txt create mode 100644 pylint/test/functional/wildcard_import.py create mode 100644 pylint/test/functional/wildcard_import.txt delete mode 100644 pylint/test/input/func_noerror_factory_method.py delete mode 100644 pylint/test/input/func_used_before_assignment_py30.py delete mode 100644 pylint/test/input/func_w0302.py delete mode 100644 pylint/test/input/func_w0402.py delete mode 100644 pylint/test/input/func_w0702.py delete mode 100644 pylint/test/messages/func_used_before_assignment_py30.txt delete mode 100644 pylint/test/messages/func_w0302.txt delete mode 100644 pylint/test/messages/func_w0402.txt delete mode 100644 pylint/test/messages/func_w0702.txt diff --git a/pylint/test/functional/bare_except.py b/pylint/test/functional/bare_except.py new file mode 100644 index 0000000..47a2079 --- /dev/null +++ b/pylint/test/functional/bare_except.py @@ -0,0 +1,6 @@ +# pylint: disable=missing-docstring, import-error + +try: + 1 + "2" +except: # [bare-except] + pass diff --git a/pylint/test/functional/bare_except.txt b/pylint/test/functional/bare_except.txt new file mode 100644 index 0000000..ccb7ba9 --- /dev/null +++ b/pylint/test/functional/bare_except.txt @@ -0,0 +1 @@ +bare-except:5::No exception type(s) specified \ No newline at end of file diff --git a/pylint/test/functional/too_many_lines.py b/pylint/test/functional/too_many_lines.py new file mode 100644 index 0000000..78e568c --- /dev/null +++ b/pylint/test/functional/too_many_lines.py @@ -0,0 +1,1015 @@ +# pylint: disable=missing-docstring +# -1: [too-many-lines] +__revision__ = 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +ZERFZAER = 3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +HEHEHE = 2 diff --git a/pylint/test/functional/too_many_lines.txt b/pylint/test/functional/too_many_lines.txt new file mode 100644 index 0000000..0374f0c --- /dev/null +++ b/pylint/test/functional/too_many_lines.txt @@ -0,0 +1 @@ +too-many-lines:1::Too many lines in module (1015/1000) \ No newline at end of file diff --git a/pylint/test/functional/used_before_assignment_nonlocal.py b/pylint/test/functional/used_before_assignment_nonlocal.py new file mode 100644 index 0000000..ef6e152 --- /dev/null +++ b/pylint/test/functional/used_before_assignment_nonlocal.py @@ -0,0 +1,47 @@ +"""Check for nonlocal and used-before-assignment""" +# pylint: disable=missing-docstring, unused-variable, no-init, too-few-public-methods + +__revision__ = 0 + +def test_ok(): + """ uses nonlocal """ + cnt = 1 + def wrap(): + nonlocal cnt + cnt = cnt + 1 + wrap() + +def test_fail(): + """ doesn't use nonlocal """ + cnt = 1 + def wrap(): + cnt = cnt + 1 # [used-before-assignment] + wrap() + +def test_fail2(): + """ use nonlocal, but for other variable """ + cnt = 1 + count = 1 + def wrap(): + nonlocal count + cnt = cnt + 1 # [used-before-assignment] + wrap() + +def test_fail3(arg: test_fail4): # [used-before-assignment] + """ Depends on `test_fail4`, in argument annotation. """ + return arg +# +1: [used-before-assignment, used-before-assignment] +def test_fail4(*args: test_fail5, **kwargs: undefined): + """ Depends on `test_fail5` and `undefined` in + variable and named arguments annotations. + """ + return args, kwargs + +def test_fail5()->undefined1: # [used-before-assignment] + """ Depends on `undefined1` in function return annotation. """ + +def undefined(): + """ no op """ + +def undefined1(): + """ no op """ diff --git a/pylint/test/functional/used_before_assignment_nonlocal.rc b/pylint/test/functional/used_before_assignment_nonlocal.rc new file mode 100644 index 0000000..c093be2 --- /dev/null +++ b/pylint/test/functional/used_before_assignment_nonlocal.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.0 diff --git a/pylint/test/functional/used_before_assignment_nonlocal.txt b/pylint/test/functional/used_before_assignment_nonlocal.txt new file mode 100644 index 0000000..36e635e --- /dev/null +++ b/pylint/test/functional/used_before_assignment_nonlocal.txt @@ -0,0 +1,6 @@ +used-before-assignment:18:test_fail.wrap:Using variable 'cnt' before assignment +used-before-assignment:27:test_fail2.wrap:Using variable 'cnt' before assignment +used-before-assignment:30:test_fail3:Using variable 'test_fail4' before assignment +used-before-assignment:34:test_fail4:Using variable 'test_fail5' before assignment +used-before-assignment:34:test_fail4:Using variable 'undefined' before assignment +used-before-assignment:40:test_fail5:Using variable 'undefined1' before assignment \ No newline at end of file diff --git a/pylint/test/functional/wildcard_import.py b/pylint/test/functional/wildcard_import.py new file mode 100644 index 0000000..4cccb6b --- /dev/null +++ b/pylint/test/functional/wildcard_import.py @@ -0,0 +1,5 @@ +# pylint: disable=no-absolute-import,missing-docstring,import-error +from indirect1 import * # [wildcard-import] +# This is an unresolved import which still generates the wildcard-import +# warning. +from unknown.package import * # [wildcard-import] diff --git a/pylint/test/functional/wildcard_import.txt b/pylint/test/functional/wildcard_import.txt new file mode 100644 index 0000000..643d818 --- /dev/null +++ b/pylint/test/functional/wildcard_import.txt @@ -0,0 +1,2 @@ +wildcard-import:2::Wildcard import indirect1 +wildcard-import:5::Wildcard import unknown.package diff --git a/pylint/test/input/func_noerror_factory_method.py b/pylint/test/input/func_noerror_factory_method.py deleted file mode 100644 index 9574bd3..0000000 --- a/pylint/test/input/func_noerror_factory_method.py +++ /dev/null @@ -1,23 +0,0 @@ -# pylint: disable=R0903 -"""use new astroid context sensitive inference""" - - -class Super(object): - """super class""" - def __init__(self): - self.bla = None - - def instance(cls): - """factory method""" - return cls() - instance = classmethod(instance) - -class Sub(Super): - """dub class""" - def method(self): - """specific method""" - return 'method called', self - -# should see the Sub.instance() is returning a Sub instance, not a Super -# instance -Sub.instance().method() diff --git a/pylint/test/input/func_used_before_assignment_py30.py b/pylint/test/input/func_used_before_assignment_py30.py deleted file mode 100644 index ae979a1..0000000 --- a/pylint/test/input/func_used_before_assignment_py30.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Check for nonlocal and used-before-assignment""" -# pylint: disable=missing-docstring, unused-variable, no-init, too-few-public-methods - -__revision__ = 0 - -def test_ok(): - """ uses nonlocal """ - cnt = 1 - def wrap(): - nonlocal cnt - cnt = cnt + 1 - wrap() - -def test_fail(): - """ doesn't use nonlocal """ - cnt = 1 - def wrap(): - cnt = cnt + 1 - wrap() - -def test_fail2(): - """ use nonlocal, but for other variable """ - cnt = 1 - count = 1 - def wrap(): - nonlocal count - cnt = cnt + 1 - wrap() - -def test_fail3(arg: test_fail4): - """ Depends on `test_fail4`, in argument annotation. """ - return arg - -def test_fail4(*args: test_fail5, **kwargs: undefined): - """ Depends on `test_fail5` and `undefined` in - variable and named arguments annotations. - """ - return args, kwargs - -def test_fail5()->undefined1: - """ Depends on `undefined1` in function return annotation. """ - -def undefined(): - """ no op """ - -def undefined1(): - """ no op """ - diff --git a/pylint/test/input/func_w0302.py b/pylint/test/input/func_w0302.py deleted file mode 100644 index a78f479..0000000 --- a/pylint/test/input/func_w0302.py +++ /dev/null @@ -1,1016 +0,0 @@ -"""test too much line in modules -""" - -__revision__ = 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -ZERFZAER = 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -HEHEHE = 2 diff --git a/pylint/test/input/func_w0402.py b/pylint/test/input/func_w0402.py deleted file mode 100644 index fcf2fc1..0000000 --- a/pylint/test/input/func_w0402.py +++ /dev/null @@ -1,12 +0,0 @@ -"""test wildard import -""" -__revision__ = 0 -# pylint: disable=no-absolute-import -from input.indirect1 import * -# This is an unresolved import which still generates the wildcard-import -# warning. -from unknown.package import * - -def abcd(): - """use imports""" - TotoInterface() diff --git a/pylint/test/input/func_w0702.py b/pylint/test/input/func_w0702.py deleted file mode 100644 index 800f4c1..0000000 --- a/pylint/test/input/func_w0702.py +++ /dev/null @@ -1,17 +0,0 @@ -"""check empty except statement -""" -from __future__ import print_function -__revision__ = 0 -# pylint: disable=using-constant-test -if __revision__: - try: - print(__revision__) - except: - print('error') - -try: - __revision__ += 1 -except TypeError: - print('error') -except Exception: - print('error') diff --git a/pylint/test/messages/func_used_before_assignment_py30.txt b/pylint/test/messages/func_used_before_assignment_py30.txt deleted file mode 100644 index 8bb131d..0000000 --- a/pylint/test/messages/func_used_before_assignment_py30.txt +++ /dev/null @@ -1,6 +0,0 @@ -E: 18:test_fail.wrap: Using variable 'cnt' before assignment -E: 27:test_fail2.wrap: Using variable 'cnt' before assignment -E: 30:test_fail3: Using variable 'test_fail4' before assignment -E: 34:test_fail4: Using variable 'test_fail5' before assignment -E: 34:test_fail4: Using variable 'undefined' before assignment -E: 40:test_fail5: Using variable 'undefined1' before assignment \ No newline at end of file diff --git a/pylint/test/messages/func_w0302.txt b/pylint/test/messages/func_w0302.txt deleted file mode 100644 index 26d509c..0000000 --- a/pylint/test/messages/func_w0302.txt +++ /dev/null @@ -1,2 +0,0 @@ -C: 1: Too many lines in module (1016/1000) - diff --git a/pylint/test/messages/func_w0402.txt b/pylint/test/messages/func_w0402.txt deleted file mode 100644 index 3bbcc5d..0000000 --- a/pylint/test/messages/func_w0402.txt +++ /dev/null @@ -1,3 +0,0 @@ -E: 8: Unable to import 'unknown.package' -W: 5: Wildcard import input.indirect1 -W: 8: Wildcard import unknown.package diff --git a/pylint/test/messages/func_w0702.txt b/pylint/test/messages/func_w0702.txt deleted file mode 100644 index d40a837..0000000 --- a/pylint/test/messages/func_w0702.txt +++ /dev/null @@ -1,2 +0,0 @@ -W: 9: No exception type(s) specified -W: 16: Catching too general exception Exception -- cgit v1.2.1