def test_borg(self): """test that the ASTNGManager is really a borg, i.e. that two different instances has same cache""" first_manager = ASTNGManager() built = first_manager.astng_from_module_name(BUILTINS_NAME) second_manager = ASTNGManager() second_built = first_manager.astng_from_module_name(BUILTINS_NAME) self.assertTrue(built is second_built)
def __init__(self, args): ConfigurationMixIn.__init__(self, usage=__doc__) insert_default_options() self.manager = ASTNGManager() self.register_options_provider(self.manager) args = self.load_command_line_configuration() self.run(args)
def brainless_manager(self): manager = ASTNGManager() # avoid caching into the ASTNGManager borg since we get problems # with other tests : manager.__dict__ = {} manager.astng_cache = {} manager._mod_file_cache = {} manager.transformers = {} return manager
# make all node classes accessible from astng package from logilab.astng.nodes import * # trigger extra monkey-patching from logilab.astng import inference # more stuff available from logilab.astng import raw_building from logilab.astng.bases import YES, Instance, BoundMethod, UnboundMethod from logilab.astng.node_classes import are_exclusive, unpack_infer from logilab.astng.scoped_nodes import builtin_lookup # make a manager instance (borg) as well as Project and Package classes # accessible from astng package from logilab.astng.manager import ASTNGManager, Project MANAGER = ASTNGManager() del ASTNGManager # load brain plugins from os import listdir from os.path import join, dirname BRAIN_MODULES_DIR = join(dirname(__file__), 'brain') if BRAIN_MODULES_DIR not in sys.path: # add it to the end of the list so user path take precedence sys.path.append(BRAIN_MODULES_DIR) # load modules in this directory for module in listdir(BRAIN_MODULES_DIR): if module.endswith('.py'): __import__(module[:-3])
def setUp(self): self.manager = ASTNGManager() self.builder = ASTNGBuilder(self.manager) self.manager.astng_cache.clear()
def setUp(self): self.manager = ASTNGManager(borg=False)