def testImport(self): self.assertEqual(builtin_value, None, "The builtin is loaded before import!") try: self.assertEqual(builtin.value, builtin.get_value()) except: self.fail("Import failed for builtin") from imports import overrideme cls1 = CLS1() self.assertTrue(CLS is CLS1, "CLS is CLS1") self.assertTrue(isinstance(cls1, CLS), "isinstance(cls1, CLS)") self.assertEqual(overrideme, "not overridden") import imports.override self.assertEqual(overrideme, "not overridden") from imports import overrideme try: self.assertTrue(overrideme.overridden is True, "overrideme.overridden is True") except: self.fail("Exception on 'overrideme.overridden is True'") import imports self.assertTrue(CLS is imports.loccls.CLS, "CLS is imports.loccls.CLS") self.assertTrue(CLS is imports.upcls.CLS, "CLS is imports.upcls.CLS")
def testImport(self): self.assertEqual(builtin_value, None, "The builtin is loaded before import!") try: self.assertEqual(builtin.value, builtin.get_value()) except: self.fail("Import failed for builtin") from imports import overrideme cls1 = CLS1() self.assertTrue(CLS is CLS1, "CLS is CLS1") self.assertTrue(isinstance(cls1, CLS), "isinstance(cls1, CLS)") self.assertEqual(overrideme, "not overridden") import imports.override self.assertEqual(overrideme, "not overridden") from imports import overrideme try: self.assertTrue(overrideme.overridden is True, "overrideme.overridden is True") except: self.fail("Exception on 'overrideme.overridden is True'") import imports self.assertTrue(CLS is imports.loccls.CLS, "CLS is imports.loccls.CLS") self.assertTrue(CLS is imports.upcls.CLS, "CLS is imports.upcls.CLS") # from ... import * tests, issue #615 self.assertEqual(imports.all_masked, False, "from ... import * should respect __all__, #615") self.assertEqual(imports.all_override, True, "Should override globals, #615") self.assertEqual(imports.all_import1, 1) self.assertEqual(imports.all_import2, 3) self.assertEqual(imports.all_import3, 3)