diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-01 11:13:50 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-01 11:13:50 +0300 |
commit | 4b338683b504b1e4a185c09b191512e79757d46e (patch) | |
tree | 88c5f1c0cbb66a78c9cbb13b61740384bc556cc0 /pylint/test | |
parent | 6354d5ab66c119ed05ec3faa71c27a520b862e3d (diff) | |
download | pylint-4b338683b504b1e4a185c09b191512e79757d46e.tar.gz |
Port more old style tests to new style tests.
Diffstat (limited to 'pylint/test')
20 files changed, 98 insertions, 144 deletions
diff --git a/pylint/test/functional/exec_used_py2.py b/pylint/test/functional/exec_used_py2.py new file mode 100644 index 0000000..8f7f07d --- /dev/null +++ b/pylint/test/functional/exec_used_py2.py @@ -0,0 +1,10 @@ +# pylint: disable=missing-docstring + +exec 'a = __revision__' # [exec-used] +VALUES = {} +exec 'a = 1' in VALUES # [exec-used] + +exec 'a = 1' in globals() # [exec-used] + +def func(): + exec 'b = 1' # [exec-used] diff --git a/pylint/test/functional/exec_used_py2.rc b/pylint/test/functional/exec_used_py2.rc new file mode 100644 index 0000000..a650233 --- /dev/null +++ b/pylint/test/functional/exec_used_py2.rc @@ -0,0 +1,2 @@ +[testoptions] +max_pyver=3.0 diff --git a/pylint/test/functional/exec_used_py2.txt b/pylint/test/functional/exec_used_py2.txt new file mode 100644 index 0000000..6b0e7d1 --- /dev/null +++ b/pylint/test/functional/exec_used_py2.txt @@ -0,0 +1,4 @@ +exec-used:3::Use of exec
+exec-used:5::Use of exec
+exec-used:7::Use of exec
+exec-used:10:func:Use of exec
\ No newline at end of file diff --git a/pylint/test/functional/exec_used_py3.py b/pylint/test/functional/exec_used_py3.py new file mode 100644 index 0000000..c6e819b --- /dev/null +++ b/pylint/test/functional/exec_used_py3.py @@ -0,0 +1,10 @@ +# pylint: disable=missing-docstring + +exec('a = __revision__') # [exec-used] +exec('a = 1', globals={}) # [exec-used] + +exec('a = 1', globals=globals()) # [exec-used] + +def func(): + exec('b = 1') # [exec-used] + diff --git a/pylint/test/functional/exec_used_py3.rc b/pylint/test/functional/exec_used_py3.rc new file mode 100644 index 0000000..c093be2 --- /dev/null +++ b/pylint/test/functional/exec_used_py3.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.0 diff --git a/pylint/test/functional/exec_used_py3.txt b/pylint/test/functional/exec_used_py3.txt new file mode 100644 index 0000000..6788574 --- /dev/null +++ b/pylint/test/functional/exec_used_py3.txt @@ -0,0 +1,4 @@ +exec-used:3::Use of exec
+exec-used:4::Use of exec
+exec-used:6::Use of exec
+exec-used:9:func:Use of exec
\ No newline at end of file diff --git a/pylint/test/input/func_toolonglines.py b/pylint/test/functional/line_too_long.py index 272395f..0baf10f 100644 --- a/pylint/test/input/func_toolonglines.py +++ b/pylint/test/functional/line_too_long.py @@ -1,27 +1,26 @@ -##################################################################################################### -""" that one is too long tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo loooooong""" - -__revision__ = '' - -# The next line is exactly 80 characters long. -A = '--------------------------------------------------------------------------' - -# The next line is longer than 80 characters, because the file is encoded -# in ASCII. -THIS_IS_A_VERY_LONG_VARIABLE_NAME = 'Существительное Частица' # With warnings. - -# Do not trigger the line-too-long warning if the only token that makes the -# line longer than 80 characters is a trailing pylint disable. -var = 'This line has a disable pragma and whitespace trailing beyond 80 chars. ' # pylint:disable=invalid-name - -badname = 'This line is already longer than 100 characters even without the pragma. Trust me. Please.' # pylint:disable=invalid-name - -# http://example.com/this/is/a/very/long/url?but=splitting&urls=is&a=pain&so=they&can=be&long - - -def function(): - """This is a docstring. - - That contains a very, very long line that exceeds the 100 characters limit by a good margin. So good? - """ - pass +# pylint: disable=invalid-encoded-data
+# +1: [line-too-long]
+#####################################################################################################
+# +1: [line-too-long]
+""" that one is too long tooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo loooooong"""
+
+# The next line is exactly 80 characters long.
+A = '--------------------------------------------------------------------------'
+
+# Do not trigger the line-too-long warning if the only token that makes the
+# line longer than 80 characters is a trailing pylint disable.
+var = 'This line has a disable pragma and whitespace trailing beyond 80 chars. ' # pylint:disable=invalid-name
+
+# +1: [line-too-long]
+badname = 'This line is already longer than 100 characters even without the pragma. Trust me. Please.' # pylint:disable=invalid-name
+
+# http://example.com/this/is/a/very/long/url?but=splitting&urls=is&a=pain&so=they&can=be&long
+
+
+def function():
+ # +3: [line-too-long]
+ """This is a docstring.
+
+ That contains a very, very long line that exceeds the 100 characters limit by a good margin. So good?
+ """
+ pass
diff --git a/pylint/test/functional/line_too_long.txt b/pylint/test/functional/line_too_long.txt new file mode 100644 index 0000000..1f02bfd --- /dev/null +++ b/pylint/test/functional/line_too_long.txt @@ -0,0 +1,4 @@ +line-too-long:3::Line too long (101/100) +line-too-long:5::Line too long (104/100) +line-too-long:15::Line too long (102/100) +line-too-long:24::Line too long (105/100) diff --git a/pylint/test/input/func_non_iterator_returned_py30.py b/pylint/test/functional/non_iterator_returned.py index 6915768..845500b 100644 --- a/pylint/test/input/func_non_iterator_returned_py30.py +++ b/pylint/test/functional/non_iterator_returned.py @@ -21,6 +21,10 @@ class SecondGoodIterator(object): """ Infinite iterator, but still an iterator """ return 1 + def next(self): # pylint: disable=no-self-use + """Same as __next__, but for Python 2.""" + return 1 + class ThirdGoodIterator(object): """ Returns other iterator, not the current instance """ @@ -36,17 +40,17 @@ class FourthGoodIterator(object): class FirstBadIterator(object): """ __iter__ returns a list """ - def __iter__(self): + def __iter__(self): # [non-iterator-returned] return [] class SecondBadIterator(object): """ __iter__ without next """ - def __iter__(self): + def __iter__(self): # [non-iterator-returned] return self class ThirdBadIterator(object): """ __iter__ returns an instance of another non-iterator """ - def __iter__(self): + def __iter__(self): # [non-iterator-returned] return SecondBadIterator() diff --git a/pylint/test/functional/non_iterator_returned.txt b/pylint/test/functional/non_iterator_returned.txt new file mode 100644 index 0000000..f2881eb --- /dev/null +++ b/pylint/test/functional/non_iterator_returned.txt @@ -0,0 +1,3 @@ +non-iterator-returned:43:FirstBadIterator.__iter__:__iter__ returns non-iterator +non-iterator-returned:49:SecondBadIterator.__iter__:__iter__ returns non-iterator +non-iterator-returned:55:ThirdBadIterator.__iter__:__iter__ returns non-iterator
\ No newline at end of file diff --git a/pylint/test/functional/undefined_variable_py30.py b/pylint/test/functional/undefined_variable_py30.py index 40cbdcc..712a096 100644 --- a/pylint/test/functional/undefined_variable_py30.py +++ b/pylint/test/functional/undefined_variable_py30.py @@ -45,14 +45,34 @@ class FalsePositive342(object): top = 42 - def test_good(self, abc: top): + def test_good(self, bac: top): """ top is defined at this moment. """ - def test_bad(self, abc: trop): # [undefined-variable] + def test_bad(self, bac: trop): # [undefined-variable] """ trop is undefined at this moment. """ def test_bad1(self, *args: trop1): # [undefined-variable] """ trop1 is undefined at this moment. """ - def test_bad2(self, **abc: trop2): # [undefined-variable] + def test_bad2(self, **bac: trop2): # [undefined-variable] """ trop2 is undefined at this moment. """ + +from abc import ABCMeta + +class Bad(metaclass=ABCMet): # [undefined-variable] + """ Notice the typo """ + +class SecondBad(metaclass=ab.ABCMeta): # [undefined-variable] + """ Notice the `ab` module. """ + +class Good(metaclass=int): + """ int is not a proper metaclass, but it is defined. """ + +class SecondGood(metaclass=Good): + """ empty """ + +class ThirdGood(metaclass=ABCMeta): + """ empty """ + +class FourthGood(ThirdGood): + """ This should not trigger anything. """ diff --git a/pylint/test/functional/undefined_variable_py30.txt b/pylint/test/functional/undefined_variable_py30.txt index f6a7596..28f67d3 100644 --- a/pylint/test/functional/undefined_variable_py30.txt +++ b/pylint/test/functional/undefined_variable_py30.txt @@ -3,4 +3,6 @@ undefined-variable:33:Undefined1.InnerScope.test_undefined:Undefined variable 'U undefined-variable:36:Undefined1.InnerScope.test1:Undefined variable 'ABC'
undefined-variable:51:FalsePositive342.test_bad:Undefined variable 'trop'
undefined-variable:54:FalsePositive342.test_bad1:Undefined variable 'trop1'
-undefined-variable:57:FalsePositive342.test_bad2:Undefined variable 'trop2'
\ No newline at end of file +undefined-variable:57:FalsePositive342.test_bad2:Undefined variable 'trop2'
+undefined-variable:62:Bad:Undefined variable 'ABCMet'
+undefined-variable:65:SecondBad:Undefined variable 'ab.ABCMeta'
\ No newline at end of file diff --git a/pylint/test/input/func_exec_used_py30.py b/pylint/test/input/func_exec_used_py30.py deleted file mode 100644 index dbcc024..0000000 --- a/pylint/test/input/func_exec_used_py30.py +++ /dev/null @@ -1,13 +0,0 @@ -"""test global statement""" - -__revision__ = 0 - -exec('a = __revision__') -exec('a = 1', globals={}) - -exec('a = 1', globals=globals()) - -def func(): - """exec in local scope""" - exec('b = 1') - diff --git a/pylint/test/input/func_non_iterator_returned_py_30.py b/pylint/test/input/func_non_iterator_returned_py_30.py deleted file mode 100644 index ff75941..0000000 --- a/pylint/test/input/func_non_iterator_returned_py_30.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Check non-iterators returned by __iter__ """ - -# pylint: disable=too-few-public-methods - -__revision__ = 0 - -class FirstGoodIterator(object): - """ yields in iterator. """ - - def __iter__(self): - for index in range(10): - yield index - -class SecondGoodIterator(object): - """ __iter__ and next """ - - def __iter__(self): - return self - - def next(self): # pylint: disable=no-self-use - """ Infinite iterator, but still an iterator """ - return 1 - -class ThirdGoodIterator(object): - """ Returns other iterator, not the current instance """ - - def __iter__(self): - return SecondGoodIterator() - -class FourthGoodIterator(object): - """ __iter__ returns iter(...) """ - - def __iter__(self): - return iter(range(10)) - -class FirstBadIterator(object): - """ __iter__ returns a list """ - - def __iter__(self): - return [] - -class SecondBadIterator(object): - """ __iter__ without next """ - - def __iter__(self): - return self - -class ThirdBadIterator(object): - """ __iter__ returns an instance of another non-iterator """ - - def __iter__(self): - return SecondBadIterator() diff --git a/pylint/test/input/func_undefined_metaclass_var_py30.py b/pylint/test/input/func_undefined_metaclass_var_py30.py deleted file mode 100644 index 307a431..0000000 --- a/pylint/test/input/func_undefined_metaclass_var_py30.py +++ /dev/null @@ -1,27 +0,0 @@ -"""test access to undefined variables in Python 3 metaclass syntax """ -# pylint: disable=no-init, invalid-name, too-few-public-methods -__revision__ = '$Id:' - -import abc -from abc import ABCMeta - -class Bad(metaclass=ABCMet): - """ Notice the typo """ - -class SecondBad(metaclass=ab.ABCMeta): - """ Notice the `ab` module. """ - -class Good(metaclass=int): - """ int is not a proper metaclass, but it is defined. """ - -class SecondGood(metaclass=Good): - """ empty """ - -class ThirdGood(metaclass=ABCMeta): - """ empty """ - -class FourthGood(ThirdGood): - """ This should not trigger anything. """ - -data = abc -testdata = ABCMeta diff --git a/pylint/test/messages/func_exec_used_py30.txt b/pylint/test/messages/func_exec_used_py30.txt deleted file mode 100644 index 362da68..0000000 --- a/pylint/test/messages/func_exec_used_py30.txt +++ /dev/null @@ -1,4 +0,0 @@ -W: 5: Use of exec
-W: 6: Use of exec
-W: 8: Use of exec
-W: 12:func: Use of exec
diff --git a/pylint/test/messages/func_non_iterator_returned_py30.txt b/pylint/test/messages/func_non_iterator_returned_py30.txt deleted file mode 100644 index c956ae7..0000000 --- a/pylint/test/messages/func_non_iterator_returned_py30.txt +++ /dev/null @@ -1,3 +0,0 @@ -E: 39:FirstBadIterator.__iter__: __iter__ returns non-iterator -E: 45:SecondBadIterator.__iter__: __iter__ returns non-iterator -E: 51:ThirdBadIterator.__iter__: __iter__ returns non-iterator
\ No newline at end of file diff --git a/pylint/test/messages/func_non_iterator_returned_py_30.txt b/pylint/test/messages/func_non_iterator_returned_py_30.txt deleted file mode 100644 index c956ae7..0000000 --- a/pylint/test/messages/func_non_iterator_returned_py_30.txt +++ /dev/null @@ -1,3 +0,0 @@ -E: 39:FirstBadIterator.__iter__: __iter__ returns non-iterator -E: 45:SecondBadIterator.__iter__: __iter__ returns non-iterator -E: 51:ThirdBadIterator.__iter__: __iter__ returns non-iterator
\ No newline at end of file diff --git a/pylint/test/messages/func_toolonglines.txt b/pylint/test/messages/func_toolonglines.txt deleted file mode 100644 index ddf05af..0000000 --- a/pylint/test/messages/func_toolonglines.txt +++ /dev/null @@ -1,6 +0,0 @@ -C: 1: Line too long (101/100) -C: 2: Line too long (104/100) -C: 11: Line too long (101/100) -C: 17: Line too long (102/100) -C: 25: Line too long (105/100) -W: 11: Cannot decode using encoding "ascii", unexpected byte at position 37 diff --git a/pylint/test/messages/func_undefined_metaclass_var_py30.txt b/pylint/test/messages/func_undefined_metaclass_var_py30.txt deleted file mode 100644 index a82ac6a..0000000 --- a/pylint/test/messages/func_undefined_metaclass_var_py30.txt +++ /dev/null @@ -1,2 +0,0 @@ -E: 8:Bad: Undefined variable 'ABCMet'
-E: 11:SecondBad: Undefined variable 'ab.ABCMeta'
\ No newline at end of file |