Exemplo n.º 1
0
 def test2(self):
     directory_name = os.path.dirname(__file__)
     filename = os.path.join(directory_name, 'plummer128.nemo')
     file = open(filename, 'rb')
     nemofile = nemobin.NemoBinaryFile(file)
     item = nemofile.read_item()
     
     self.assertEqual(item.data, "init_xrandom: seed used 123")
     file.close()
Exemplo n.º 2
0
 def test7(self):
     directory_name = os.path.dirname(__file__)
     filename = os.path.join(directory_name, 'plummer128.nemo')
     file = open(filename, 'rb')
     nemofile = nemobin.NemoBinaryFile(file)
     data = nemofile.read()
     file.close()
     
     outputfile =  BytesIO()
     nemooutputfile = nemobin.NemoBinaryFile(outputfile)
     nemooutputfile.write(data)
     string = outputfile.getvalue()
     outputfile.close()
     
     file = open(filename, 'rb')
     original = file.read()
     file.close()
     
     self.assertEqual(len(original), len(string))
     self.assertEqual(original, string)
Exemplo n.º 3
0
 def test1(self):
     directory_name = os.path.dirname(__file__)
     filename = os.path.join(directory_name, 'plummer128.nemo')
     file = open(filename, 'rb')
     nemofile = nemobin.NemoBinaryFile(file)
     tagcharacter, tagstring, dim, mustswap = nemofile.get_item_header()
     self.assertEqual(tagcharacter, 'c')
     self.assertEqual(tagstring, 'Headline')
     self.assertEqual(len(dim), 1)
     self.assertEqual(dim[0], 28)
     file.close()
Exemplo n.º 4
0
 def test5(self):
     directory_name = os.path.dirname(__file__)
     filename = os.path.join(directory_name, 'plummer128.nemo')
     file = open(filename, 'rb')
     nemofile = nemobin.NemoBinaryFile(file)
     data = nemofile.read()
     file.close()
     
     outputfile =  BytesIO()
     nemooutputfile = nemobin.NemoBinaryFile(outputfile)
     nemooutputfile.write(data)
     string = outputfile.getvalue()
     outputfile.close()
     inputfile =  BytesIO(string)
     nemoinputfile = nemobin.NemoBinaryFile(inputfile)
     tagcharacter, tagstring, dim, mustswap = nemoinputfile.get_item_header()
     self.assertEqual(tagcharacter, 'c')
     self.assertEqual(tagstring, 'Headline')
     self.assertEqual(len(dim), 1)
     self.assertEqual(dim[0], 28)
     inputfile.close()
Exemplo n.º 5
0
 def test3(self):
     directory_name = os.path.dirname(__file__)
     filename = os.path.join(directory_name, 'plummer128.nemo')
     file = open(filename, 'rb')
     nemofile = nemobin.NemoBinaryFile(file)
     data = nemofile.read()
     file.close()
     self.assertEqual(len(data), 3)
     tags = list(data.keys())
     self.assertEqual(tags[0], 'Headline')
     self.assertEqual(tags[1], 'History')
     self.assertEqual(tags[2], 'SnapShot')
     self.assertEqual(data['History'][0].data, 'mkplummer out=plummer128.nemo nbody=128 seed=123 VERSION=2.8b')
     
     self.assertEqual(len(data['SnapShot'][0].data), 2)
     tags = list(data['SnapShot'][0].data.keys())
     self.assertEqual(tags[0], 'Parameters')
     self.assertEqual(tags[1], 'Particles')
Exemplo n.º 6
0
 def test6(self):        
     inputfile = BytesIO()
     nemoinputfile = nemobin.NemoBinaryFile(inputfile)
     data = nemoinputfile.read()
     self.assertEqual(len(data), 0)