MCPcopy Index your code
hub / github.com/python/cpython / mkhier

Method mkhier

Lib/test/test_pkg.py:72–92  ·  view source on GitHub ↗
(self, descr)

Source from the content-addressed store, hash-verified

70 exec(textwrap.dedent(code), globals(), {"self": self})
71
72 def mkhier(self, descr):
73 root = tempfile.mkdtemp()
74 sys.path.insert(0, root)
75 if not os.path.isdir(root):
76 os.mkdir(root)
77 for name, contents in descr:
78 comps = name.split()
79 self.modules_to_cleanup.add('.'.join(comps))
80 fullname = root
81 for c in comps:
82 fullname = os.path.join(fullname, c)
83 if contents is None:
84 os.mkdir(fullname)
85 else:
86 with open(fullname, "w") as f:
87 f.write(contents)
88 if not contents.endswith('\n'):
89 f.write('\n')
90 self.root = root
91 # package name is the name of the first item
92 self.pkgname = descr[0][0]
93
94 def test_1(self):
95 hier = [("t1", None), ("t1 __init__.py", "")]

Callers 8

test_1Method · 0.95
test_2Method · 0.95
test_3Method · 0.95
test_4Method · 0.95
test_5Method · 0.95
test_6Method · 0.95
test_7Method · 0.95
test_8Method · 0.95

Calls 10

mkdtempMethod · 0.80
openFunction · 0.50
insertMethod · 0.45
isdirMethod · 0.45
mkdirMethod · 0.45
splitMethod · 0.45
addMethod · 0.45
joinMethod · 0.45
writeMethod · 0.45
endswithMethod · 0.45

Tested by

no test coverage detected