Example #1
0
 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)
Example #2
0
    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
Example #3
0
 def test12(self):
     t12 = [1, 2]
     none = import_from_string("t12.2")
     assert none is None
Example #4
0
    def test10(self):
        class C(object):
            value = 10

        c = C()
        assert import_from_string("c.value") == 10
Example #5
0
 def test09(self):
     t09 = "hello"
     v09 = import_from_string("t09")
     assert v09 == t09
Example #6
0
 def test08(self):
     none = import_from_string("not-exist-module")
     assert none is None
Example #7
0
 def test06(self):
     listdir = import_from_string("os.listdir")
     assert callable(listdir)
Example #8
0
 def test05(self):
     os = import_from_string("os")
     assert hasattr(os, "listdir")