本文整理汇总了Python中exe.engine.path.Path.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Path.delete方法的具体用法?Python Path.delete怎么用?Python Path.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testReferenceCounting
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import delete [as 别名]
def testReferenceCounting(self):
"""
Make 3 resources with different names but same md5, ensure they are reference counted properly
"""
res1 = Path('my.resource1.bin')
res2 = Path('my.resource2.bin')
res3 = Path('my.resource3.bin')
for res in (res1, res2, res3):
res.write_bytes('SOME NICE DATA')
res1md5 = res1.md5
res4 = Path('tmp/my.resource1.bin')
if not res4.dirname().exists():
res4.dirname().makedirs()
res4.write_bytes('SOME *DIFFERENT* DATA')
res4md5 = res4.md5
res1, res2, res3, res4 = map(lambda f: Resource(self.package, f), (res1, res2, res3, res4))
assert res1.storageName == 'my.resource1.bin', res1.storageName
assert res2.storageName == 'my.resource1.bin', res2.storageName
assert res3.storageName == 'my.resource1.bin', res3.storageName
assert res4.storageName == 'my.resource1.1.bin', res4.storageName
assert res4.userName == 'my.resource1.bin', res4.userName
assert len(self.package.resources) == 2
assert len(self.package.resources[res1.path.md5]) == 3
assert len(self.package.resources[res4.path.md5]) == 1
assert self.package.resources[res4md5][0] is res4
# Now start deleting things
res4path = Path(res4.path)
assert res4path.exists()
res4.delete()
assert not res4path.exists()
assert res4md5 not in self.package.resources
assert not res4path.exists()
res1path = Path(res1.path)
assert res1path.exists()
res2.delete()
assert res1path.exists()
assert res2 not in self.package.resources[res1md5]
res1.delete()
assert res1path.exists()
assert res1 not in self.package.resources[res1md5]
res3.delete()
assert res1md5 not in self.package.resources
assert not res1path.exists()