def test11(self): if os.sys.version.startswith("2.6"): self.assertRaises( ImportError, lambda: import_from_string("not-exist-module", slient=False)) else: with self.assertRaises(ImportError): import_from_string("not-exist-module", slient=False)
def test07(self): class C(object): value = 3 c = C() data = {"a": {"b": {"c": c}}} v = import_from_string("data.a.b.c.value") assert v == 3
def test12(self): t12 = [1, 2] none = import_from_string("t12.2") assert none is None
def test10(self): class C(object): value = 10 c = C() assert import_from_string("c.value") == 10
def test09(self): t09 = "hello" v09 = import_from_string("t09") assert v09 == t09
def test08(self): none = import_from_string("not-exist-module") assert none is None
def test06(self): listdir = import_from_string("os.listdir") assert callable(listdir)
def test05(self): os = import_from_string("os") assert hasattr(os, "listdir")