summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/unittest_helpers.py15
-rw-r--r--tests/unittest_inference.py24
-rw-r--r--tests/unittest_object_model.py55
-rw-r--r--tests/unittest_objects.py22
-rw-r--r--tests/unittest_regrtest.py15
-rw-r--r--tests/unittest_scoped_nodes.py223
6 files changed, 0 insertions, 354 deletions
diff --git a/tests/unittest_helpers.py b/tests/unittest_helpers.py
index 8ed07ede..b62b3afc 100644
--- a/tests/unittest_helpers.py
+++ b/tests/unittest_helpers.py
@@ -192,21 +192,6 @@ class TestHelpers(unittest.TestCase):
self.assertFalse(helpers.is_subtype(cls_a, cls_b))
self.assertFalse(helpers.is_subtype(cls_a, cls_b))
- @test_utils.require_version(maxver="3.0")
- def test_is_subtype_supertype_old_style_classes(self):
- cls_a, cls_b = builder.extract_node(
- """
- class A: #@
- pass
- class B(A): #@
- pass
- """
- )
- self.assertFalse(helpers.is_subtype(cls_a, cls_b))
- self.assertFalse(helpers.is_subtype(cls_b, cls_a))
- self.assertFalse(helpers.is_supertype(cls_a, cls_b))
- self.assertFalse(helpers.is_supertype(cls_b, cls_a))
-
def test_is_subtype_supertype_mro_error(self):
cls_e, cls_f = builder.extract_node(
"""
diff --git a/tests/unittest_inference.py b/tests/unittest_inference.py
index f91960d7..7fc5990a 100644
--- a/tests/unittest_inference.py
+++ b/tests/unittest_inference.py
@@ -500,17 +500,6 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
self.assertEqual(inferred.name, "set")
self.assertIn("remove", inferred._proxied.locals)
- @test_utils.require_version(maxver="3.0")
- def test_unicode_type(self):
- code = '''u = u""'''
- ast = parse(code, __name__)
- n = ast["u"]
- inferred = next(n.infer())
- self.assertIsInstance(inferred, nodes.Const)
- self.assertIsInstance(inferred, Instance)
- self.assertEqual(inferred.name, "unicode")
- self.assertIn("lower", inferred._proxied.locals)
-
@pytest.mark.xfail(reason="Descriptors are not properly inferred as callable")
def test_descriptor_are_callable(self):
code = """
@@ -3861,19 +3850,6 @@ class InferenceTest(resources.SysPathSetup, unittest.TestCase):
inferred.getattr("teta")
inferred.getattr("a")
- @test_utils.require_version(maxver="3.0")
- def test_delayed_attributes_with_old_style_classes(self):
- ast_node = extract_node(
- """
- class A:
- __slots__ = ('a', )
- a = A()
- a.teta = 42
- a #@
- """
- )
- next(ast_node.infer()).getattr("teta")
-
def test_lambda_as_methods(self):
ast_node = extract_node(
"""
diff --git a/tests/unittest_object_model.py b/tests/unittest_object_model.py
index d201ec9b..a77afc34 100644
--- a/tests/unittest_object_model.py
+++ b/tests/unittest_object_model.py
@@ -144,30 +144,6 @@ class ClassModelTest(unittest.TestCase):
self.assertIsInstance(inferred, astroid.Const)
self.assertEqual(inferred.value, "first")
- @test_utils.require_version(maxver="3.0")
- def test__mro__old_style(self):
- ast_node = builder.extract_node(
- """
- class A:
- pass
- A.__mro__
- """
- )
- with self.assertRaises(exceptions.InferenceError):
- next(ast_node.infer())
-
- @test_utils.require_version(maxver="3.0")
- def test__subclasses__old_style(self):
- ast_node = builder.extract_node(
- """
- class A:
- pass
- A.__subclasses__
- """
- )
- with self.assertRaises(exceptions.InferenceError):
- next(ast_node.infer())
-
def test_class_model_correct_mro_subclasses_proxied(self):
ast_nodes = builder.extract_node(
"""
@@ -506,37 +482,6 @@ class FunctionModelTest(unittest.TestCase):
self.assertIsInstance(kwdefaults, astroid.Dict)
# self.assertEqual(kwdefaults.getitem('f').value, 'lala')
- @test_utils.require_version(maxver="3.0")
- def test_function_model_for_python2(self):
- ast_nodes = builder.extract_node(
- """
- def test(a=1):
- "a"
-
- test.func_name #@
- test.func_doc #@
- test.func_dict #@
- test.func_globals #@
- test.func_defaults #@
- test.func_code #@
- test.func_closure #@
- """
- )
- name = next(ast_nodes[0].infer())
- self.assertIsInstance(name, astroid.Const)
- self.assertEqual(name.value, "test")
- doc = next(ast_nodes[1].infer())
- self.assertIsInstance(doc, astroid.Const)
- self.assertEqual(doc.value, "a")
- pydict = next(ast_nodes[2].infer())
- self.assertIsInstance(pydict, astroid.Dict)
- pyglobals = next(ast_nodes[3].infer())
- self.assertIsInstance(pyglobals, astroid.Dict)
- defaults = next(ast_nodes[4].infer())
- self.assertIsInstance(defaults, astroid.Tuple)
- for node in ast_nodes[5:]:
- self.assertIs(next(node.infer()), astroid.Uninferable)
-
@test_utils.require_version(minver="3.8")
def test_annotation_positional_only(self):
ast_node = builder.extract_node(
diff --git a/tests/unittest_objects.py b/tests/unittest_objects.py
index 8c56c9fd..9111477f 100644
--- a/tests/unittest_objects.py
+++ b/tests/unittest_objects.py
@@ -96,28 +96,6 @@ class SuperTests(unittest.TestCase):
self.assertIsInstance(second, bases.Instance)
self.assertEqual(second.qname(), "%s.super" % bases.BUILTINS)
- @test_utils.require_version(maxver="3.0")
- def test_super_on_old_style_class(self):
- # super doesn't work on old style class, but leave
- # that as an error for pylint. We'll infer Super objects,
- # but every call will result in a failure at some point.
- node = builder.extract_node(
- """
- class OldStyle:
- def __init__(self):
- super(OldStyle, self) #@
- """
- )
- old = next(node.infer())
- self.assertIsInstance(old, objects.Super)
- self.assertIsInstance(old.mro_pointer, nodes.ClassDef)
- self.assertEqual(old.mro_pointer.name, "OldStyle")
- with self.assertRaises(exceptions.SuperError) as cm:
- old.super_mro()
- self.assertEqual(
- str(cm.exception), "Unable to call super on old-style classes."
- )
-
@test_utils.require_version(minver="3.0")
def test_no_arguments_super(self):
ast_nodes = builder.extract_node(
diff --git a/tests/unittest_regrtest.py b/tests/unittest_regrtest.py
index 8224494b..92ed5b65 100644
--- a/tests/unittest_regrtest.py
+++ b/tests/unittest_regrtest.py
@@ -306,21 +306,6 @@ def test():
)
next(node.infer())
- @require_version(maxver="3.0")
- def test_reassignment_in_except_handler(self):
- node = extract_node(
- """
- import exceptions
- try:
- {}["a"]
- except KeyError, exceptions.IndexError:
- pass
-
- IndexError #@
- """
- )
- self.assertEqual(len(node.inferred()), 1)
-
class Whatever:
a = property(lambda x: x, lambda x: x)
diff --git a/tests/unittest_scoped_nodes.py b/tests/unittest_scoped_nodes.py
index d70b7351..7f422d4f 100644
--- a/tests/unittest_scoped_nodes.py
+++ b/tests/unittest_scoped_nodes.py
@@ -1005,19 +1005,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
self.assertEqual(astroid["g2"].fromlineno, 9)
self.assertEqual(astroid["g2"].tolineno, 10)
- @test_utils.require_version(maxver="3.0")
- def test_simple_metaclass(self):
- astroid = builder.parse(
- """
- class Test(object):
- __metaclass__ = type
- """
- )
- klass = astroid["Test"]
- metaclass = klass.metaclass()
- self.assertIsInstance(metaclass, scoped_nodes.ClassDef)
- self.assertEqual(metaclass.name, "type")
-
def test_metaclass_error(self):
astroid = builder.parse(
"""
@@ -1028,21 +1015,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
klass = astroid["Test"]
self.assertFalse(klass.metaclass())
- @test_utils.require_version(maxver="3.0")
- def test_metaclass_imported(self):
- astroid = builder.parse(
- """
- from abc import ABCMeta
- class Test(object):
- __metaclass__ = ABCMeta
- """
- )
- klass = astroid["Test"]
-
- metaclass = klass.metaclass()
- self.assertIsInstance(metaclass, scoped_nodes.ClassDef)
- self.assertEqual(metaclass.name, "ABCMeta")
-
def test_metaclass_yes_leak(self):
astroid = builder.parse(
"""
@@ -1056,100 +1028,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
klass = astroid["Meta"]
self.assertIsNone(klass.metaclass())
- @test_utils.require_version(maxver="3.0")
- def test_newstyle_and_metaclass_good(self):
- astroid = builder.parse(
- """
- from abc import ABCMeta
- class Test:
- __metaclass__ = ABCMeta
- """
- )
- klass = astroid["Test"]
- self.assertTrue(klass.newstyle)
- self.assertEqual(klass.metaclass().name, "ABCMeta")
- astroid = builder.parse(
- """
- from abc import ABCMeta
- __metaclass__ = ABCMeta
- class Test:
- pass
- """
- )
- klass = astroid["Test"]
- self.assertTrue(klass.newstyle)
- self.assertEqual(klass.metaclass().name, "ABCMeta")
-
- @test_utils.require_version(maxver="3.0")
- def test_nested_metaclass(self):
- astroid = builder.parse(
- """
- from abc import ABCMeta
- class A(object):
- __metaclass__ = ABCMeta
- class B: pass
-
- __metaclass__ = ABCMeta
- class C:
- __metaclass__ = type
- class D: pass
- """
- )
- a = astroid["A"]
- b = a.locals["B"][0]
- c = astroid["C"]
- d = c.locals["D"][0]
- self.assertEqual(a.metaclass().name, "ABCMeta")
- self.assertFalse(b.newstyle)
- self.assertIsNone(b.metaclass())
- self.assertEqual(c.metaclass().name, "type")
- self.assertEqual(d.metaclass().name, "ABCMeta")
-
- @test_utils.require_version(maxver="3.0")
- def test_parent_metaclass(self):
- astroid = builder.parse(
- """
- from abc import ABCMeta
- class Test:
- __metaclass__ = ABCMeta
- class SubTest(Test): pass
- """
- )
- klass = astroid["SubTest"]
- self.assertTrue(klass.newstyle)
- metaclass = klass.metaclass()
- self.assertIsInstance(metaclass, scoped_nodes.ClassDef)
- self.assertEqual(metaclass.name, "ABCMeta")
-
- @test_utils.require_version(maxver="3.0")
- def test_metaclass_ancestors(self):
- astroid = builder.parse(
- """
- from abc import ABCMeta
-
- class FirstMeta(object):
- __metaclass__ = ABCMeta
-
- class SecondMeta(object):
- __metaclass__ = type
-
- class Simple(object):
- pass
-
- class FirstImpl(FirstMeta): pass
- class SecondImpl(FirstImpl): pass
- class ThirdImpl(Simple, SecondMeta):
- pass
- """
- )
- classes = {"ABCMeta": ("FirstImpl", "SecondImpl"), "type": ("ThirdImpl",)}
- for metaclass, names in classes.items():
- for name in names:
- impl = astroid[name]
- meta = impl.metaclass()
- self.assertIsInstance(meta, nodes.ClassDef)
- self.assertEqual(meta.name, metaclass)
-
def test_metaclass_type(self):
klass = builder.extract_node(
"""
@@ -1314,33 +1192,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
else:
self.assertEqual(list(expected_value), [node.value for node in slots])
- @test_utils.require_version(maxver="3.0")
- def test_slots_py2(self):
- module = builder.parse(
- """
- class UnicodeSlots(object):
- __slots__ = (u"a", u"b", "c")
- """
- )
- slots = module["UnicodeSlots"].slots()
- self.assertEqual(len(slots), 3)
- self.assertEqual(slots[0].value, "a")
- self.assertEqual(slots[1].value, "b")
- self.assertEqual(slots[2].value, "c")
-
- @test_utils.require_version(maxver="3.0")
- def test_slots_py2_not_implemented(self):
- module = builder.parse(
- """
- class OldStyle:
- __slots__ = ("a", "b")
- """
- )
- msg = "The concept of slots is undefined for old-style classes."
- with self.assertRaises(NotImplementedError) as cm:
- module["OldStyle"].slots()
- self.assertEqual(str(cm.exception), msg)
-
def test_slots_for_dict_keys(self):
module = builder.parse(
"""
@@ -1400,71 +1251,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
def assertEqualMro(self, klass, expected_mro):
self.assertEqual([member.name for member in klass.mro()], expected_mro)
- @test_utils.require_version(maxver="3.0")
- def test_no_mro_for_old_style(self):
- node = builder.extract_node(
- """
- class Old: pass"""
- )
- with self.assertRaises(NotImplementedError) as cm:
- node.mro()
- self.assertEqual(
- str(cm.exception), "Could not obtain mro for " "old-style classes."
- )
-
- @test_utils.require_version(maxver="3.0")
- def test_mro_for_classes_with_old_style_in_mro(self):
- node = builder.extract_node(
- """
- class Factory:
- pass
- class ClientFactory(Factory):
- pass
- class ReconnectingClientFactory(ClientFactory):
- pass
- class WebSocketAdapterFactory(object):
- pass
- class WebSocketClientFactory(WebSocketAdapterFactory, ClientFactory):
- pass
- class WampWebSocketClientFactory(WebSocketClientFactory):
- pass
- class RetryFactory(WampWebSocketClientFactory, ReconnectingClientFactory):
- pas
- """
- )
- self.assertEqualMro(
- node,
- [
- "RetryFactory",
- "WampWebSocketClientFactory",
- "WebSocketClientFactory",
- "WebSocketAdapterFactory",
- "object",
- "ReconnectingClientFactory",
- "ClientFactory",
- "Factory",
- ],
- )
-
- @test_utils.require_version(maxver="3.0")
- def test_combined_newstyle_oldstyle_in_mro(self):
- node = builder.extract_node(
- """
- class Old:
- pass
- class New(object):
- pass
- class New1(object):
- pass
- class New2(New, New1):
- pass
- class NewOld(New2, Old): #@
- pass
- """
- )
- self.assertEqualMro(node, ["NewOld", "New2", "New", "New1", "object", "Old"])
- self.assertTrue(node.newstyle)
-
def test_with_metaclass_mro(self):
astroid = builder.parse(
"""
@@ -1741,15 +1527,6 @@ class ClassNodeTest(ModuleLoader, unittest.TestCase):
static = next(acls.igetattr("static"))
self.assertIsInstance(static, scoped_nodes.FunctionDef)
- @test_utils.require_version(maxver="3.0")
- def test_implicit_metaclass_is_none(self):
- cls = builder.extract_node(
- """
- class A: pass
- """
- )
- self.assertIsNone(cls.implicit_metaclass())
-
def test_local_attr_invalid_mro(self):
cls = builder.extract_node(
"""