diff options
author | Ceridwen <ceridwenv@gmail.com> | 2015-11-02 00:10:54 -0500 |
---|---|---|
committer | Ceridwen <ceridwenv@gmail.com> | 2015-11-02 00:10:54 -0500 |
commit | 1ba0f2d96fbc45ff0b6014b12db98716183e8277 (patch) | |
tree | 54b7c4d3ecad6fcda1211ea3a8e5f11f6b407287 /astroid/tests/unittest_objects.py | |
parent | 83f6c45c343cae87f415268959b1056030a5e74c (diff) | |
download | astroid-1ba0f2d96fbc45ff0b6014b12db98716183e8277.tar.gz |
This bookmark adds structured exceptions to astroid.
Major changes:
* AstroidError has an __init__ that accepts arbitrary keyword-only
arguments for adding information to exceptions, and a __str__ that
lazily uses exception attributes to generate a message. The first
positional argument to an exception is assigned to .message. The new
API should be fully backwards compatible in general.
* Some exceptions are combined or renamed; the old names are still
available.
* The OperationErrors used by pylint are now BadOperationMessages and
located in util.py.
* The AstroidBuildingException in _data_build stores the SyntaxError
in its .error attribute rather than args[0].
* Many places where exceptions are raised have new, hopefully more
useful error messages.
The only major issue remaining is how to propagate information into decorators.
Diffstat (limited to 'astroid/tests/unittest_objects.py')
-rw-r--r-- | astroid/tests/unittest_objects.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/astroid/tests/unittest_objects.py b/astroid/tests/unittest_objects.py index e0a04d5..dc91d94 100644 --- a/astroid/tests/unittest_objects.py +++ b/astroid/tests/unittest_objects.py @@ -233,15 +233,15 @@ class SuperTests(unittest.TestCase): self.assertIsInstance(first, objects.Super)
with self.assertRaises(exceptions.SuperError) as cm:
first.super_mro()
- self.assertEqual(str(cm.exception), "The first super argument must be type.")
- for node in ast_nodes[1:]:
+ self.assertIsInstance(cm.exception.super_.mro_pointer, nodes.Const)
+ self.assertEqual(cm.exception.super_.mro_pointer.value, 1)
+ for node, invalid_type in zip(ast_nodes[1:],
+ (nodes.Const, bases.Instance)):
inferred = next(node.infer())
self.assertIsInstance(inferred, objects.Super, node)
- with self.assertRaises(exceptions.SuperArgumentTypeError) as cm:
+ with self.assertRaises(exceptions.SuperError) as cm:
inferred.super_mro()
- self.assertEqual(str(cm.exception),
- "super(type, obj): obj must be an instance "
- "or subtype of type", node)
+ self.assertIsInstance(cm.exception.super_.type, invalid_type)
def test_proxied(self):
node = test_utils.extract_node('''
@@ -338,9 +338,9 @@ class SuperTests(unittest.TestCase): with self.assertRaises(exceptions.InferenceError):
next(ast_nodes[2].infer())
fourth = next(ast_nodes[3].infer())
- with self.assertRaises(exceptions.NotFoundError):
+ with self.assertRaises(exceptions.AttributeInferenceError):
fourth.getattr('test3')
- with self.assertRaises(exceptions.NotFoundError):
+ with self.assertRaises(exceptions.AttributeInferenceError):
next(fourth.igetattr('test3'))
first_unbound = next(ast_nodes[4].infer())
@@ -362,7 +362,7 @@ class SuperTests(unittest.TestCase): super(Super, self) #@
''')
inferred = next(node.infer())
- with self.assertRaises(exceptions.NotFoundError):
+ with self.assertRaises(exceptions.AttributeInferenceError):
next(inferred.getattr('test'))
def test_super_complex_mro(self):
@@ -491,7 +491,7 @@ class SuperTests(unittest.TestCase): inferred = next(node.infer())
with self.assertRaises(exceptions.SuperError):
inferred.super_mro()
- with self.assertRaises(exceptions.SuperArgumentTypeError):
+ with self.assertRaises(exceptions.SuperError):
inferred.super_mro()
|