From 7678723873ca872d9f92032fc7cb8cc93709ad9a Mon Sep 17 00:00:00 2001 From: cpopa Date: Mon, 14 Apr 2014 16:39:47 +0300 Subject: Fix tests for < Python 2.7. --- test/input/func_format.py | 108 ------------------------------------ test/input/func_format_py27.py | 108 ++++++++++++++++++++++++++++++++++++ test/input/func_format_py_27.py | 103 ++++++++++++++++++++++++++++++++++ test/messages/func_format.txt | 46 --------------- test/messages/func_format_py27.txt | 46 +++++++++++++++ test/messages/func_format_py_27.txt | 45 +++++++++++++++ test/unittest_checkers_utils.py | 6 +- 7 files changed, 305 insertions(+), 157 deletions(-) delete mode 100644 test/input/func_format.py create mode 100644 test/input/func_format_py27.py create mode 100644 test/input/func_format_py_27.py delete mode 100644 test/messages/func_format.txt create mode 100644 test/messages/func_format_py27.txt create mode 100644 test/messages/func_format_py_27.txt diff --git a/test/input/func_format.py b/test/input/func_format.py deleted file mode 100644 index 828a180..0000000 --- a/test/input/func_format.py +++ /dev/null @@ -1,108 +0,0 @@ -# pylint:disable=C0103,W0104,W0105 -"""Check format -""" -__revision__ = '' - -notpreceded= 1 -notfollowed =1 -notfollowed <=1 - -correct = 1 -correct >= 1 - -def func(arg, arg2): - """test named argument - """ - func(arg=arg+1, - arg2=arg2-arg) - -aaaa,bbbb = 1,2 -aaaa |= bbbb -aaaa &= bbbb - - -if aaaa: pass -else: - aaaa,bbbb = 1,2 - aaaa,bbbb = bbbb,aaaa - -bbbb = (1,2,3) - -aaaa = bbbb[1:] -aaaa = bbbb[:1] -aaaa = bbbb[:] - -aaaa = {aaaa:bbbb} - - -# allclose(x,y) uses |x-y|ist genau gleich -yo+=4 -""" -html2 = """ -yo+=4 -""" - -func('''Hello -''', 0) - -assert boo <= 10, "Note is %.2f. Either you cheated, or pylint's \ -broken!" % boo - -def _gc_debug(gcc): - """bad format undetected w/ py2.5""" - ocount = {} - for obj in gcc.get_objects(): - try: - ocount[obj.__class__]+= 1 - except KeyError: - ocount[obj.__class__]=1 - except AttributeError: - pass - -def hop(context): - """multi-lines string""" - return [''' -%(send)s%(send)s''' % context, - ''' -%(cancel)s%(cancel)s''' % context, - ] -titreprojet = '\ -Drapeau vert\ -%s' % aaaa - -with open('a') as a, open('b') as b: - pass - -with open('a') as a, open('b') as b: pass # multiple-statements - -# Well-formatted try-except-finally block. -try: - pass -except IOError, e: - print e -finally: - pass - -try: - pass -except IOError, e: - print e -finally: pass # multiple-statements - -# This is not allowed by the default configuration. -if True: print False diff --git a/test/input/func_format_py27.py b/test/input/func_format_py27.py new file mode 100644 index 0000000..828a180 --- /dev/null +++ b/test/input/func_format_py27.py @@ -0,0 +1,108 @@ +# pylint:disable=C0103,W0104,W0105 +"""Check format +""" +__revision__ = '' + +notpreceded= 1 +notfollowed =1 +notfollowed <=1 + +correct = 1 +correct >= 1 + +def func(arg, arg2): + """test named argument + """ + func(arg=arg+1, + arg2=arg2-arg) + +aaaa,bbbb = 1,2 +aaaa |= bbbb +aaaa &= bbbb + + +if aaaa: pass +else: + aaaa,bbbb = 1,2 + aaaa,bbbb = bbbb,aaaa + +bbbb = (1,2,3) + +aaaa = bbbb[1:] +aaaa = bbbb[:1] +aaaa = bbbb[:] + +aaaa = {aaaa:bbbb} + + +# allclose(x,y) uses |x-y|ist genau gleich +yo+=4 +""" +html2 = """ +yo+=4 +""" + +func('''Hello +''', 0) + +assert boo <= 10, "Note is %.2f. Either you cheated, or pylint's \ +broken!" % boo + +def _gc_debug(gcc): + """bad format undetected w/ py2.5""" + ocount = {} + for obj in gcc.get_objects(): + try: + ocount[obj.__class__]+= 1 + except KeyError: + ocount[obj.__class__]=1 + except AttributeError: + pass + +def hop(context): + """multi-lines string""" + return [''' +%(send)s%(send)s''' % context, + ''' +%(cancel)s%(cancel)s''' % context, + ] +titreprojet = '\ +Drapeau vert\ +%s' % aaaa + +with open('a') as a, open('b') as b: + pass + +with open('a') as a, open('b') as b: pass # multiple-statements + +# Well-formatted try-except-finally block. +try: + pass +except IOError, e: + print e +finally: + pass + +try: + pass +except IOError, e: + print e +finally: pass # multiple-statements + +# This is not allowed by the default configuration. +if True: print False diff --git a/test/input/func_format_py_27.py b/test/input/func_format_py_27.py new file mode 100644 index 0000000..f062f27 --- /dev/null +++ b/test/input/func_format_py_27.py @@ -0,0 +1,103 @@ +# pylint:disable=C0103,W0104,W0105 +"""Check format +""" +__revision__ = '' + +notpreceded= 1 +notfollowed =1 +notfollowed <=1 + +correct = 1 +correct >= 1 + +def func(arg, arg2): + """test named argument + """ + func(arg=arg+1, + arg2=arg2-arg) + +aaaa,bbbb = 1,2 +aaaa |= bbbb +aaaa &= bbbb + + +if aaaa: pass +else: + aaaa,bbbb = 1,2 + aaaa,bbbb = bbbb,aaaa + +bbbb = (1,2,3) + +aaaa = bbbb[1:] +aaaa = bbbb[:1] +aaaa = bbbb[:] + +aaaa = {aaaa:bbbb} + + +# allclose(x,y) uses |x-y|ist genau gleich +yo+=4 +""" +html2 = """ +yo+=4 +""" + +func('''Hello +''', 0) + +assert boo <= 10, "Note is %.2f. Either you cheated, or pylint's \ +broken!" % boo + +def _gc_debug(gcc): + """bad format undetected w/ py2.5""" + ocount = {} + for obj in gcc.get_objects(): + try: + ocount[obj.__class__]+= 1 + except KeyError: + ocount[obj.__class__]=1 + except AttributeError: + pass + +def hop(context): + """multi-lines string""" + return [''' +%(send)s%(send)s''' % context, + ''' +%(cancel)s%(cancel)s''' % context, + ] +titreprojet = '\ +Drapeau vert\ +%s' % aaaa + +# Well-formatted try-except-finally block. +try: + pass +except IOError, e: + print e +finally: + pass + +try: + pass +except IOError, e: + print e +finally: pass # multiple-statements + +# This is not allowed by the default configuration. +if True: print False diff --git a/test/messages/func_format.txt b/test/messages/func_format.txt deleted file mode 100644 index ce5df81..0000000 --- a/test/messages/func_format.txt +++ /dev/null @@ -1,46 +0,0 @@ -C: 6: Exactly one space required before assignment -notpreceded= 1 - ^ -C: 7: Exactly one space required after assignment -notfollowed =1 - ^ -C: 8: Exactly one space required after comparison -notfollowed <=1 - ^^ -C: 19: Exactly one space required after comma -aaaa,bbbb = 1,2 - ^ -C: 19: Exactly one space required after comma -aaaa,bbbb = 1,2 - ^ -C: 24: More than one statement on a single line -C: 26: Exactly one space required after comma - aaaa,bbbb = 1,2 - ^ -C: 26: Exactly one space required after comma - aaaa,bbbb = 1,2 - ^ -C: 27: Exactly one space required after comma - aaaa,bbbb = bbbb,aaaa - ^ -C: 27: Exactly one space required after comma - aaaa,bbbb = bbbb,aaaa - ^ -C: 29: Exactly one space required after comma -bbbb = (1,2,3) - ^ -C: 29: Exactly one space required after comma -bbbb = (1,2,3) - ^ -C: 51: Exactly one space required before assignment - funky= funky+2 - ^ -C: 71: Exactly one space required before assignment - ocount[obj.__class__]+= 1 - ^^ -C: 73: Exactly one space required around assignment - ocount[obj.__class__]=1 - ^ -C: 91: More than one statement on a single line -C:105: More than one statement on a single line -C:108: More than one statement on a single line diff --git a/test/messages/func_format_py27.txt b/test/messages/func_format_py27.txt new file mode 100644 index 0000000..ce5df81 --- /dev/null +++ b/test/messages/func_format_py27.txt @@ -0,0 +1,46 @@ +C: 6: Exactly one space required before assignment +notpreceded= 1 + ^ +C: 7: Exactly one space required after assignment +notfollowed =1 + ^ +C: 8: Exactly one space required after comparison +notfollowed <=1 + ^^ +C: 19: Exactly one space required after comma +aaaa,bbbb = 1,2 + ^ +C: 19: Exactly one space required after comma +aaaa,bbbb = 1,2 + ^ +C: 24: More than one statement on a single line +C: 26: Exactly one space required after comma + aaaa,bbbb = 1,2 + ^ +C: 26: Exactly one space required after comma + aaaa,bbbb = 1,2 + ^ +C: 27: Exactly one space required after comma + aaaa,bbbb = bbbb,aaaa + ^ +C: 27: Exactly one space required after comma + aaaa,bbbb = bbbb,aaaa + ^ +C: 29: Exactly one space required after comma +bbbb = (1,2,3) + ^ +C: 29: Exactly one space required after comma +bbbb = (1,2,3) + ^ +C: 51: Exactly one space required before assignment + funky= funky+2 + ^ +C: 71: Exactly one space required before assignment + ocount[obj.__class__]+= 1 + ^^ +C: 73: Exactly one space required around assignment + ocount[obj.__class__]=1 + ^ +C: 91: More than one statement on a single line +C:105: More than one statement on a single line +C:108: More than one statement on a single line diff --git a/test/messages/func_format_py_27.txt b/test/messages/func_format_py_27.txt new file mode 100644 index 0000000..20cba32 --- /dev/null +++ b/test/messages/func_format_py_27.txt @@ -0,0 +1,45 @@ +C: 6: Exactly one space required before assignment +notpreceded= 1 + ^ +C: 7: Exactly one space required after assignment +notfollowed =1 + ^ +C: 8: Exactly one space required after comparison +notfollowed <=1 + ^^ +C: 19: Exactly one space required after comma +aaaa,bbbb = 1,2 + ^ +C: 19: Exactly one space required after comma +aaaa,bbbb = 1,2 + ^ +C: 24: More than one statement on a single line +C: 26: Exactly one space required after comma + aaaa,bbbb = 1,2 + ^ +C: 26: Exactly one space required after comma + aaaa,bbbb = 1,2 + ^ +C: 27: Exactly one space required after comma + aaaa,bbbb = bbbb,aaaa + ^ +C: 27: Exactly one space required after comma + aaaa,bbbb = bbbb,aaaa + ^ +C: 29: Exactly one space required after comma +bbbb = (1,2,3) + ^ +C: 29: Exactly one space required after comma +bbbb = (1,2,3) + ^ +C: 51: Exactly one space required before assignment + funky= funky+2 + ^ +C: 71: Exactly one space required before assignment + ocount[obj.__class__]+= 1 + ^^ +C: 73: Exactly one space required around assignment + ocount[obj.__class__]=1 + ^ +C:100: More than one statement on a single line +C:103: More than one statement on a single line diff --git a/test/unittest_checkers_utils.py b/test/unittest_checkers_utils.py index d8ebd3b..72108d7 100644 --- a/test/unittest_checkers_utils.py +++ b/test/unittest_checkers_utils.py @@ -18,10 +18,10 @@ __revision__ = '$Id: unittest_checkers_utils.py,v 1.6 2005-11-02 09:22:07 syt Exp $' -import unittest import sys from astroid import test_utils +from logilab.common.testlib import TestCase, unittest_main from pylint.checkers import utils try: @@ -29,7 +29,7 @@ try: except AttributeError: __builtins__['mybuiltin'] = 2 -class UtilsTC(unittest.TestCase): +class UtilsTC(TestCase): ## def test_is_native_builtin(self): ## self.assertEqual(utils.is_native_builtin('min'), True) @@ -70,5 +70,5 @@ class UtilsTC(unittest.TestCase): self.assertEqual(name.name, 'a') if __name__ == '__main__': - unittest.main() + unittest_main() -- cgit v1.2.1