From 14c9cec686658bf96e0695213bc8d692dfbfddd4 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Tue, 9 Mar 2021 20:44:38 +0100 Subject: Migrate func_dotted_ancestor.py to new functional tests --- tests/functional/d/dotted_ancestor.py | 11 +++++++ tests/functional/d/dotted_ancestor.txt | 1 + tests/functional/d/func_w0233.py | 51 +++++++++++++++++++++++++++++++++ tests/functional/d/func_w0233.txt | 6 ++++ tests/input/func_dotted_ancestor.py | 11 ------- tests/input/func_w0233.py | 51 --------------------------------- tests/messages/func_dotted_ancestor.txt | 1 - tests/messages/func_w0233.txt | 6 ---- tests/test_func.py | 2 +- 9 files changed, 70 insertions(+), 70 deletions(-) create mode 100644 tests/functional/d/dotted_ancestor.py create mode 100644 tests/functional/d/dotted_ancestor.txt create mode 100644 tests/functional/d/func_w0233.py create mode 100644 tests/functional/d/func_w0233.txt delete mode 100644 tests/input/func_dotted_ancestor.py delete mode 100644 tests/input/func_w0233.py delete mode 100644 tests/messages/func_dotted_ancestor.txt delete mode 100644 tests/messages/func_w0233.txt diff --git a/tests/functional/d/dotted_ancestor.py b/tests/functional/d/dotted_ancestor.py new file mode 100644 index 000000000..3c136591e --- /dev/null +++ b/tests/functional/d/dotted_ancestor.py @@ -0,0 +1,11 @@ +"""bla""" +# pylint: disable=no-absolute-import + +from . import func_w0233 + +__revision__ = 'yo' + +class Aaaa(func_w0233.AAAA): # [too-few-public-methods] + """test dotted name in ancestors""" + def __init__(self): + func_w0233.AAAA.__init__(self) diff --git a/tests/functional/d/dotted_ancestor.txt b/tests/functional/d/dotted_ancestor.txt new file mode 100644 index 000000000..4aa47e7c2 --- /dev/null +++ b/tests/functional/d/dotted_ancestor.txt @@ -0,0 +1 @@ +too-few-public-methods:8:0:Aaaa:Too few public methods (0/2) diff --git a/tests/functional/d/func_w0233.py b/tests/functional/d/func_w0233.py new file mode 100644 index 000000000..ca0345db3 --- /dev/null +++ b/tests/functional/d/func_w0233.py @@ -0,0 +1,51 @@ +# pylint: disable=R0903,W0212,W0406,no-absolute-import,wrong-import-order, useless-object-inheritance + +"""test for call to __init__ from a non ancestor class +""" +from __future__ import print_function +from . import func_w0233 +import nonexistant # [import-error] +__revision__ = '$Id: func_w0233.py,v 1.2 2004-09-29 08:35:13 syt Exp $' + +class AAAA(object): + """ancestor 1""" + + def __init__(self): + print('init', self) + BBBBMixin.__init__(self) # [non-parent-init-called] + +class BBBBMixin(object): + """ancestor 2""" + + def __init__(self): + print('init', self) + +class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB, nonexistant.AClass): # [no-member] + """mix different things, some inferable some not""" + def __init__(self): + BBBBMixin.__init__(self) + func_w0233.AAAA.__init__(self) + func_w0233.BBBB.__init__(self) # [no-member] + nonexistant.AClass.__init__(self) + +class DDDD(AAAA): + """call superclass constructor in disjunct branches""" + def __init__(self, value): + if value: + AAAA.__init__(self) + else: + AAAA.__init__(self) + +class Super(dict): + """ test late binding super() call """ + def __init__(self): + base = super() + base.__init__() + +class Super2(dict): + """ Using the same idiom as Super, but without calling + the __init__ method. + """ + def __init__(self): # [super-init-not-called] + base = super() + base.__woohoo__() # [no-member] diff --git a/tests/functional/d/func_w0233.txt b/tests/functional/d/func_w0233.txt new file mode 100644 index 000000000..a05215ae2 --- /dev/null +++ b/tests/functional/d/func_w0233.txt @@ -0,0 +1,6 @@ +import-error:7:0::Unable to import 'nonexistant' +non-parent-init-called:15:8:AAAA.__init__:__init__ method from a non direct base class 'BBBBMixin' is called +no-member:23:38:CCC:Module 'functional.d.func_w0233' has no 'BBBB' member:INFERENCE +no-member:28:8:CCC.__init__:Module 'functional.d.func_w0233' has no 'BBBB' member:INFERENCE +super-init-not-called:49:4:Super2.__init__:__init__ method from base class 'dict' is not called +no-member:51:8:Super2.__init__:Super of 'Super2' has no '__woohoo__' member:INFERENCE diff --git a/tests/input/func_dotted_ancestor.py b/tests/input/func_dotted_ancestor.py deleted file mode 100644 index ff3285803..000000000 --- a/tests/input/func_dotted_ancestor.py +++ /dev/null @@ -1,11 +0,0 @@ -"""bla""" -# pylint: disable=no-absolute-import - -from input import func_w0233 - -__revision__ = 'yo' - -class Aaaa(func_w0233.AAAA): - """test dotted name in ancestors""" - def __init__(self): - func_w0233.AAAA.__init__(self) diff --git a/tests/input/func_w0233.py b/tests/input/func_w0233.py deleted file mode 100644 index feb30c567..000000000 --- a/tests/input/func_w0233.py +++ /dev/null @@ -1,51 +0,0 @@ -# pylint: disable=R0903,W0212,W0406,no-absolute-import,wrong-import-order, useless-object-inheritance - -"""test for call to __init__ from a non ancestor class -""" -from __future__ import print_function -from . import func_w0233 -import nonexistant -__revision__ = '$Id: func_w0233.py,v 1.2 2004-09-29 08:35:13 syt Exp $' - -class AAAA(object): - """ancestor 1""" - - def __init__(self): - print('init', self) - BBBBMixin.__init__(self) - -class BBBBMixin(object): - """ancestor 2""" - - def __init__(self): - print('init', self) - -class CCC(BBBBMixin, func_w0233.AAAA, func_w0233.BBBB, nonexistant.AClass): - """mix different things, some inferable some not""" - def __init__(self): - BBBBMixin.__init__(self) - func_w0233.AAAA.__init__(self) - func_w0233.BBBB.__init__(self) - nonexistant.AClass.__init__(self) - -class DDDD(AAAA): - """call superclass constructor in disjunct branches""" - def __init__(self, value): - if value: - AAAA.__init__(self) - else: - AAAA.__init__(self) - -class Super(dict): - """ test late binding super() call """ - def __init__(self): - base = super() - base.__init__() - -class Super2(dict): - """ Using the same idiom as Super, but without calling - the __init__ method. - """ - def __init__(self): - base = super() - base.__woohoo__() diff --git a/tests/messages/func_dotted_ancestor.txt b/tests/messages/func_dotted_ancestor.txt deleted file mode 100644 index 6e2c6fa5e..000000000 --- a/tests/messages/func_dotted_ancestor.txt +++ /dev/null @@ -1 +0,0 @@ -R: 8:Aaaa: Too few public methods (0/2) diff --git a/tests/messages/func_w0233.txt b/tests/messages/func_w0233.txt deleted file mode 100644 index de4f0fba9..000000000 --- a/tests/messages/func_w0233.txt +++ /dev/null @@ -1,6 +0,0 @@ -E: 7: Unable to import 'nonexistant' -E: 23:CCC: Module 'input.func_w0233' has no 'BBBB' member -E: 28:CCC.__init__: Module 'input.func_w0233' has no 'BBBB' member -E: 51:Super2.__init__: Super of 'Super2' has no '__woohoo__' member -W: 15:AAAA.__init__: __init__ method from a non direct base class 'BBBBMixin' is called -W: 49:Super2.__init__: __init__ method from base class 'dict' is not called diff --git a/tests/test_func.py b/tests/test_func.py index f96e53c28..891363f6a 100644 --- a/tests/test_func.py +++ b/tests/test_func.py @@ -120,7 +120,7 @@ def gen_tests(filter_rgx): tests.append((module_file, messages_file, dependencies)) if UPDATE_FILE.exists(): return tests - assert len(tests) < 19, "Please do not add new test cases here." + assert len(tests) < 18, "Please do not add new test cases here." return tests -- cgit v1.2.1