本文整理汇总了Python中bravo.nbt.NBTFile.write_file方法的典型用法代码示例。如果您正苦于以下问题:Python NBTFile.write_file方法的具体用法?Python NBTFile.write_file怎么用?Python NBTFile.write_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bravo.nbt.NBTFile
的用法示例。
在下文中一共展示了NBTFile.write_file方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EmptyStringTest
# 需要导入模块: from bravo.nbt import NBTFile [as 别名]
# 或者: from bravo.nbt.NBTFile import write_file [as 别名]
class EmptyStringTest(unittest.TestCase):
def setUp(self):
self.golden_value = "\x0A\0\x04Test\x08\0\x0Cempty string\0\0\0"
self.nbtfile = NBTFile(buffer=StringIO(self.golden_value))
def testReadEmptyString(self):
self.assertEqual(self.nbtfile.name, "Test")
self.assertEqual(self.nbtfile["empty string"].value, "")
def testWriteEmptyString(self):
buffer = StringIO()
self.nbtfile.write_file(buffer=buffer)
self.assertEqual(buffer.getvalue(), self.golden_value)
示例2: testWriteback
# 需要导入模块: from bravo.nbt import NBTFile [as 别名]
# 或者: from bravo.nbt.NBTFile import write_file [as 别名]
def testWriteback(self):
mynbt = NBTFile(self.f.name)
mynbt.write_file()
示例3: testWriteBig
# 需要导入模块: from bravo.nbt import NBTFile [as 别名]
# 或者: from bravo.nbt.NBTFile import write_file [as 别名]
def testWriteBig(self):
mynbt = NBTFile(self.f.name)
output = StringIO()
mynbt.write_file(buffer=output)
self.assertTrue(GzipFile(self.f.name).read() == output.getvalue())