本文整理汇总了Python中sos.archive.TarFileArchive.close方法的典型用法代码示例。如果您正苦于以下问题:Python TarFileArchive.close方法的具体用法?Python TarFileArchive.close怎么用?Python TarFileArchive.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sos.archive.TarFileArchive
的用法示例。
在下文中一共展示了TarFileArchive.close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TarFileArchiveTest
# 需要导入模块: from sos.archive import TarFileArchive [as 别名]
# 或者: from sos.archive.TarFileArchive import close [as 别名]
class TarFileArchiveTest(unittest.TestCase):
def setUp(self):
self.tf = TarFileArchive('test')
def tearDown(self):
os.unlink(self.tf.name())
def check_for_file(self, filename):
rtf = tarfile.open('test.tar')
rtf.getmember(filename)
rtf.close()
def test_create(self):
self.tf.close()
self.assertTrue(os.path.exists('test.tar'))
def test_add_file(self):
self.tf.add_file('tests/ziptest')
self.tf.close()
self.check_for_file('test/tests/ziptest')
# Since commit 179d9bb add_file does not support recursive directory
# addition. Disable this test for now.
# def test_add_dir(self):
# self.tf.add_file('tests/')
# self.tf.close()
#
# self.check_for_file('test/tests/ziptest')
def test_add_renamed(self):
self.tf.add_file('tests/ziptest', dest='tests/ziptest_renamed')
self.tf.close()
self.check_for_file('test/tests/ziptest_renamed')
# Since commit 179d9bb add_file does not support recursive directory
# addition. Disable this test for now.
# def test_add_renamed_dir(self):
# self.tf.add_file('tests/', 'tests_renamed/')
# self.tf.close()
#
# self.check_for_file('test/tests_renamed/ziptest')
def test_add_string(self):
self.tf.add_string('this is content', 'tests/string_test.txt')
self.tf.close()
self.check_for_file('test/tests/string_test.txt')
def test_get_file(self):
self.tf.add_string('this is my content', 'tests/string_test.txt')
afp = self.tf.open_file('tests/string_test.txt')
self.assertEquals('this is my content', afp.read())
def test_overwrite_file(self):
self.tf.add_string('this is my content', 'tests/string_test.txt')
self.tf.add_string('this is my new content', 'tests/string_test.txt')
afp = self.tf.open_file('tests/string_test.txt')
self.assertEquals('this is my new content', afp.read())
def test_make_link(self):
self.tf.add_file('tests/ziptest')
self.tf.add_link('tests/ziptest', 'link_name')
self.tf.close()
self.check_for_file('test/link_name')
def test_compress(self):
name = self.tf.compress("gzip")