summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Thénault <sylvain.thenault@logilab.fr>2007-02-16 17:55:59 +0100
committerSylvain Thénault <sylvain.thenault@logilab.fr>2007-02-16 17:55:59 +0100
commit132f18c5a925c2fd5b6a9ac75455314933a190f8 (patch)
tree10eaf72201b5acb8df7cb3a95767945fe6c4f940
parent937932879e14d9fa3a5c8aa5f493412a4a2d12de (diff)
downloadpylint-git-132f18c5a925c2fd5b6a9ac75455314933a190f8.tar.gz
add factory method test, other test fixes
-rw-r--r--test/input/func_noerror_factory_method.py23
-rw-r--r--test/regrtest.py2
-rw-r--r--test/rpythoninput/func_noerror_multiple_inheritance.py5
-rw-r--r--test/test_import_graph.py2
4 files changed, 28 insertions, 4 deletions
diff --git a/test/input/func_noerror_factory_method.py b/test/input/func_noerror_factory_method.py
new file mode 100644
index 000000000..026ec0fb2
--- /dev/null
+++ b/test/input/func_noerror_factory_method.py
@@ -0,0 +1,23 @@
+# pylint: disable-msg=R0903
+"""use new astng context sensitive inference"""
+__revision__ = 1
+
+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"""
+ print 'method called', self
+
+# should see the Sub.instance() is returning a Sub instance, not a Super
+# instance
+Sub.instance().method()
diff --git a/test/regrtest.py b/test/regrtest.py
index 9868b3cf7..c8fe42a20 100644
--- a/test/regrtest.py
+++ b/test/regrtest.py
@@ -120,7 +120,7 @@ class NonRegrTC(TestCase):
def test_decimal_inference(self):
linter.check('regrtest_data/decimal_inference.py')
got = linter.reporter.finalize().strip()
- self.failUnlessEqual(got, "E: 7: Instance of 'Context' has no 'prec' member")
+ self.failUnlessEqual(got, "E: 7: Instance of 'Context' has no 'prec' member (but some types could not be inferred)")
def test_descriptor_crash(self):
for fname in os.listdir('regrtest_data'):
diff --git a/test/rpythoninput/func_noerror_multiple_inheritance.py b/test/rpythoninput/func_noerror_multiple_inheritance.py
index 9efc94aa0..050b2c380 100644
--- a/test/rpythoninput/func_noerror_multiple_inheritance.py
+++ b/test/rpythoninput/func_noerror_multiple_inheritance.py
@@ -7,7 +7,7 @@ class B:
class C(A, B):
def __init__(self, a):
- A.__init__(self, a)
+ A.__init__(self)
self.attr = a
@@ -20,3 +20,6 @@ def entry_point(argv):
def target(*args):
return entry_point, None
+
+import os
+
diff --git a/test/test_import_graph.py b/test/test_import_graph.py
index c05c032f4..2d2bf023c 100644
--- a/test/test_import_graph.py
+++ b/test/test_import_graph.py
@@ -38,8 +38,6 @@ class ImportCheckerTC(unittest.TestCase):
def setUp(self):
self.linter = l = PyLinter(reporter=TestReporter())
initialize(l)
- for checker in l._checkers:
- checker.enable(False)
def test_checker_dep_graphs(self):
l = self.linter