Example #1
0
    def setUp(self):
        codes = list(collect_module_code(
            join(FILES_DIR, 'package_dependency'),
            [FILES_DIR]))
        self.descriptors = build_module_descriptors(codes)
        self.assertEqual(3, len(self.descriptors))

        init = self.descriptors['package_dependency']
        a = self.descriptors['package_dependency.a']
        b = self.descriptors['package_dependency.b']

        self.assertNotNone(init)
        self.assertNotNone(a)
        self.assertNotNone(b)

        self.assertEqual('package_dependency', init.name)
        self.assertEqual('package_dependency.a', a.name)
        self.assertEqual('package_dependency.b', b.name)
Example #2
0
    def test_import_alias(self):
        path = join(FILES_DIR, 'import_alias')
        codes = list(collect_module_code(path, path))
        descriptors = build_module_descriptors(codes)

        foo = descriptors['foo']
        bar = descriptors['bar']

        # import foo module
        syspath = sys.path[:]
        try:
            sys.path.insert(0, path)
            import foo as f

            self.assert_(
                has_subclass(bar, f.Foo),
                "The module 'bar' should contain a subclass of 'foo.Foo'")
        finally:
            sys.path = syspath
Example #3
0
 def import_modules(self, path):
     sys.path.insert(0, path)
     codes = list(collect_module_code(path, path))
     self.descriptors.update(build_module_descriptors(codes))
Example #4
0
 def setUp(self):
     codes = list(collect_module_code(
         join(FILES_DIR, 'cycles'),
         [FILES_DIR]))
     self.descriptors = build_module_descriptors(codes)
Example #5
0
 def setUp(self):
     d = join(FILES_DIR, 'imports')
     codes = list(collect_module_code(d, [d]))
     self.descriptors = build_module_descriptors(codes)
     self.assertEqual(8, len(self.descriptors))