本文整理汇总了Python中mozpack.files.GeneratedFile.copy方法的典型用法代码示例。如果您正苦于以下问题:Python GeneratedFile.copy方法的具体用法?Python GeneratedFile.copy怎么用?Python GeneratedFile.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozpack.files.GeneratedFile
的用法示例。
在下文中一共展示了GeneratedFile.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generated_file
# 需要导入模块: from mozpack.files import GeneratedFile [as 别名]
# 或者: from mozpack.files.GeneratedFile import copy [as 别名]
def test_generated_file(self):
'''
Check that GeneratedFile.copy yields the proper content in the
destination file in all situations that trigger different code paths
(see TestFile.test_file)
'''
dest = self.tmppath('dest')
for content in samples:
f = GeneratedFile(content)
f.copy(dest)
self.assertEqual(content, open(dest, 'rb').read())
示例2: test_generated_file_no_write
# 需要导入模块: from mozpack.files import GeneratedFile [as 别名]
# 或者: from mozpack.files.GeneratedFile import copy [as 别名]
def test_generated_file_no_write(self):
'''
Test various conditions where GeneratedFile.copy is expected not to
write in the destination file.
'''
dest = self.tmppath('dest')
# Initial copy
f = GeneratedFile('test')
f.copy(dest)
# Ensure subsequent copies won't trigger writes
f.copy(DestNoWrite(dest))
self.assertEqual('test', open(dest, 'rb').read())
# When using a new instance with the same content, no copy should occur
f = GeneratedFile('test')
f.copy(DestNoWrite(dest))
self.assertEqual('test', open(dest, 'rb').read())
# Double check that under conditions where a copy occurs, we would get
# an exception.
f = GeneratedFile('fooo')
self.assertRaises(RuntimeError, f.copy, DestNoWrite(dest))