本文整理汇总了Python中unipath.Path.write_link方法的典型用法代码示例。如果您正苦于以下问题:Python Path.write_link方法的具体用法?Python Path.write_link怎么用?Python Path.write_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unipath.Path
的用法示例。
在下文中一共展示了Path.write_link方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FilesystemTest
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import write_link [as 别名]
class FilesystemTest(object):
TEST_HIERARCHY = {
"a_file": "Nothing important.",
"animals": {
"elephant": "large",
"gonzo": "unique",
"mouse": "small"},
"images": {
"image1.gif": "",
"image2.jpg": "",
"image3.png": ""},
"swedish": {
"chef": {
"bork": {
"bork": "bork!"}}},
}
def setup_method(self, method):
self.d = d = Path(tempfile.mkdtemp())
dict2dir(d, self.TEST_HIERARCHY)
self.a_file = Path(d, "a_file")
self.animals = Path(d, "animals")
self.images = Path(d, "images")
self.chef = Path(d, "swedish", "chef", "bork", "bork")
if hasattr(self.d, "write_link"):
self.link_to_chef_file = Path(d, "link_to_chef_file")
self.link_to_chef_file.write_link(self.chef)
self.link_to_images_dir = Path(d, "link_to_images_dir")
self.link_to_images_dir.write_link(self.images)
self.dead_link = self.d.child("dead_link")
self.dead_link.write_link("nowhere")
self.missing = Path(d, "MISSING")
self.d.chdir()
def teardown_method(self, method):
d = self.d
d.parent.chdir() # Always need a valid curdir to avoid OSErrors.
if dump:
dump_path(d)
if cleanup:
d.rmtree()
if d.exists():
raise AssertionError("unable to delete temp dir %s" % d)
else:
print("Not deleting test directory", d)
示例2: test_rmtree_broken_symlink
# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import write_link [as 别名]
def test_rmtree_broken_symlink(self):
symlink = Path(self.d, "symlink")
symlink.write_link("broken")
assert symlink.lexists()
symlink.rmtree()
assert not symlink.lexists()