def _init_dirs(self):
test_dirs = ['a a', 'b', 'c\c', 'D_']
config = 'improbable'
root = tempfile.mkdtemp()
def cleanup():
try:
os.removedirs(root)
except (FileNotFoundError, OSError):
pass
os.chdir(root)
for dir_ in test_dirs:
os.mkdir(dir_, 0o0750)
f = '{0}.toml'.format(config)
flags = os.O_WRONLY | os.O_CREAT
rel_path = '{0}/{1}'.format(dir_, f)
abs_file_path = os.path.join(root, rel_path)
with os.fdopen(os.open(abs_file_path, flags, 0o0640), 'w') as fp:
fp.write("key = \"value is {0}\"\n".format(dir_))
return root, config, cleanup
评论列表
文章目录