summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2014-03-08 13:00:59 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2014-03-08 13:00:59 +0200
commit8b874f7dfeee1792293fe10fe6435bf381ec7d6a (patch)
treef2e9d9e08b6621a82ec705d18013fc2f2c5bb8cd /test
parented82d0d515da88a8d0b659ac30aec9d245a077d7 (diff)
downloadastroid-git-8b874f7dfeee1792293fe10fe6435bf381ec7d6a.tar.gz
Fix a false positive with builtin exceptions, by rewriting the `args` and `message` attributes with their real values.
Diffstat (limited to 'test')
-rw-r--r--test/unittest_raw_building.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/test/unittest_raw_building.py b/test/unittest_raw_building.py
index 414d8bed..8051422d 100644
--- a/test/unittest_raw_building.py
+++ b/test/unittest_raw_building.py
@@ -1,5 +1,10 @@
+from textwrap import dedent
+
from logilab.common.testlib import TestCase, unittest_main
from astroid.raw_building import (attach_dummy_node, build_module, build_class, build_function, build_from_import)
+from astroid.builder import AstroidBuilder
+from astroid.manager import AstroidManager
+from astroid.node_classes import Tuple
class RawBuildingTC(TestCase):
@@ -40,4 +45,21 @@ class RawBuildingTC(TestCase):
def test_build_from_import(self):
names = ['exceptions, inference, inspector']
node = build_from_import('astroid', names)
- self.assertEqual(len(names), len(node.names)) \ No newline at end of file
+ self.assertEqual(len(names), len(node.names))
+
+ def test_exception_dynamic_attr(self):
+ # Pylint issue 32: e1101-false-positives-for-exception
+ manager = AstroidManager()
+ builder = AstroidBuilder(manager)
+ node = builder.string_build(dedent("""
+ try:
+ x[0]
+ except IndexError as err:
+ pass
+ """))
+ handler = node.body[0].handlers[0]
+ instance = handler.name.infered()[0]
+ args = instance.getattr('args')
+ for arg in args:
+ self.assertIsInstance(arg, Tuple)
+ \ No newline at end of file