MCPcopy
hub / github.com/linkedin/shiv / test_import_string

Method test_import_string

test/test_bootstrap.py:30–49  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

28
29class TestBootstrap:
30 def test_import_string(self):
31 assert import_string("site.addsitedir") == addsitedir
32 assert import_string("site:addsitedir") == addsitedir
33 assert import_string("code.interact") == interact
34 assert import_string("code:interact") == interact
35
36 # test things not already imported
37 func = import_string("os.path:join")
38 from os.path import join
39
40 assert func == join
41
42 # test something already imported
43 import shiv
44
45 assert import_string("shiv") == shiv == sys.modules["shiv"]
46
47 # test bogus imports raise properly
48 with pytest.raises(ImportError):
49 import_string("this is bogus!")
50
51 def test_is_zipfile(self, zip_location):
52 with mock.patch.object(sys, "argv", [zip_location]):

Callers

nothing calls this directly

Calls 1

import_stringFunction · 0.90

Tested by

no test coverage detected