当前位置: 首页>>代码示例>>Python>>正文


Python Path.delete方法代码示例

本文整理汇总了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()
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:45,代码来源:testresource.py


注:本文中的exe.engine.path.Path.delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。