summaryrefslogtreecommitdiff
path: root/astroid/tests/unittest_manager.py
diff options
context:
space:
mode:
Diffstat (limited to 'astroid/tests/unittest_manager.py')
-rw-r--r--astroid/tests/unittest_manager.py35
1 files changed, 22 insertions, 13 deletions
diff --git a/astroid/tests/unittest_manager.py b/astroid/tests/unittest_manager.py
index fc11643b..7e4eeae7 100644
--- a/astroid/tests/unittest_manager.py
+++ b/astroid/tests/unittest_manager.py
@@ -20,12 +20,16 @@ import platform
import sys
import unittest
-from astroid.manager import AstroidManager
-from astroid.bases import BUILTINS
-from astroid.exceptions import AstroidBuildingException
+import six
+
+from astroid import exceptions
+from astroid import manager
from astroid.tests import resources
+BUILTINS = six.moves.builtins.__name__
+
+
def _get_file_from_object(obj):
if platform.python_implementation() == 'Jython':
return obj.__file__.split("$py.class")[0] + ".py"
@@ -41,7 +45,7 @@ class AstroidManagerTest(resources.SysPathSetup,
def setUp(self):
super(AstroidManagerTest, self).setUp()
- self.manager = AstroidManager()
+ self.manager = manager.AstroidManager()
self.manager.clear_cache(self._builtins) # take care of borg
def test_ast_from_file(self):
@@ -64,7 +68,8 @@ class AstroidManagerTest(resources.SysPathSetup,
self.assertIn('unittest', self.manager.astroid_cache)
def test_ast_from_file_name_astro_builder_exception(self):
- self.assertRaises(AstroidBuildingException, self.manager.ast_from_file, 'unhandledName')
+ self.assertRaises(exceptions.AstroidBuildingException,
+ self.manager.ast_from_file, 'unhandledName')
def test_do_not_expose_main(self):
obj = self.manager.ast_from_module_name('__main__')
@@ -83,7 +88,9 @@ class AstroidManagerTest(resources.SysPathSetup,
self.assertEqual(astroid.pure_python, False)
def test_ast_from_module_name_astro_builder_exception(self):
- self.assertRaises(AstroidBuildingException, self.manager.ast_from_module_name, 'unhandledModule')
+ self.assertRaises(exceptions.AstroidBuildingException,
+ self.manager.ast_from_module_name,
+ 'unhandledModule')
def _test_ast_from_zip(self, archive):
origpath = sys.path[:]
@@ -133,7 +140,8 @@ class AstroidManagerTest(resources.SysPathSetup,
def test_file_from_module_name_astro_building_exception(self):
"""check if the method launch a exception with a wrong module name"""
- self.assertRaises(AstroidBuildingException, self.manager.file_from_module_name, 'unhandledModule', None)
+ self.assertRaises(exceptions.AstroidBuildingException,
+ self.manager.file_from_module_name, 'unhandledModule', None)
def test_ast_from_module(self):
astroid = self.manager.ast_from_module(unittest)
@@ -171,20 +179,21 @@ class AstroidManagerTest(resources.SysPathSetup,
def test_ast_from_class_attr_error(self):
"""give a wrong class at the ast_from_class method"""
- self.assertRaises(AstroidBuildingException, self.manager.ast_from_class, None)
+ self.assertRaises(exceptions.AstroidBuildingException,
+ self.manager.ast_from_class, None)
def testFailedImportHooks(self):
def hook(modname):
if modname == 'foo.bar':
return unittest
else:
- raise AstroidBuildingException()
+ raise exceptions.AstroidBuildingException()
- with self.assertRaises(AstroidBuildingException):
+ with self.assertRaises(exceptions.AstroidBuildingException):
self.manager.ast_from_module_name('foo.bar')
self.manager.register_failed_import_hook(hook)
self.assertEqual(unittest, self.manager.ast_from_module_name('foo.bar'))
- with self.assertRaises(AstroidBuildingException):
+ with self.assertRaises(exceptions.AstroidBuildingException):
self.manager.ast_from_module_name('foo.bar.baz')
del self.manager._failed_import_hooks[0]
@@ -194,10 +203,10 @@ class BorgAstroidManagerTC(unittest.TestCase):
def test_borg(self):
"""test that the AstroidManager is really a borg, i.e. that two different
instances has same cache"""
- first_manager = AstroidManager()
+ first_manager = manager.AstroidManager()
built = first_manager.ast_from_module_name(BUILTINS)
- second_manager = AstroidManager()
+ second_manager = manager.AstroidManager()
second_built = second_manager.ast_from_module_name(BUILTINS)
self.assertIs(built, second_built)