def test_parse_bundle_structure(self): # parsing flat bundle elements = list(parse_bundle(self.data1)) self.assertEqual(len(elements), 3) self.assertTrue(isinstance(elements[0], tuple)) self.assertEqual(len(elements[0]), 2) self.assertTrue(isinstance(elements[0][0], float)) self.assertTrue(isinstance(elements[0][1], tuple)) self.assertEqual(len(elements[0][1]), 3) self.assertTrue(isinstance(elements[0][1][2], tuple)) self.assertEqual(elements[0][0], elements[1][0], "timetag of first and second bundle element differ") self.assertEqual(elements[0][0], elements[2][0], "timetag of first and third bundle element differ") # parsing nested bundle elements = list(parse_bundle(self.data2)) self.assertEqual(len(elements), 2) self.assertTrue(isinstance(elements[0], tuple)) self.assertEqual(len(elements[0]), 2) self.assertTrue(isinstance(elements[0][0], float)) self.assertTrue(isinstance(elements[0][1], tuple)) self.assertEqual(len(elements[0][1]), 3) self.assertTrue(isinstance(elements[0][1][2], tuple)) self.assertEqual( elements[0][0], elements[1][0], "timetag of first element and element from nested bundle differ")
def test_parse_bundle_structure(self): # parsing flat bundle elements = list(parse_bundle(self.data1)) self.assertEqual(len(elements), 3) self.assertTrue(isinstance(elements[0], tuple)) self.assertEqual(len(elements[0]), 2) self.assertTrue(isinstance(elements[0][0], float)) self.assertTrue(isinstance(elements[0][1], tuple)) self.assertEqual(len(elements[0][1]), 3) self.assertTrue(isinstance(elements[0][1][2], tuple)) self.assertEqual(elements[0][0], elements[1][0], "timetag of first and second bundle element differ") self.assertEqual(elements[0][0], elements[2][0], "timetag of first and third bundle element differ") # parsing nested bundle elements = list(parse_bundle(self.data2)) self.assertEqual(len(elements), 2) self.assertTrue(isinstance(elements[0], tuple)) self.assertEqual(len(elements[0]), 2) self.assertTrue(isinstance(elements[0][0], float)) self.assertTrue(isinstance(elements[0][1], tuple)) self.assertEqual(len(elements[0][1]), 3) self.assertTrue(isinstance(elements[0][1][2], tuple)) self.assertEqual(elements[0][0], elements[1][0], "timetag of first element and element from nested bundle differ")
def test_parse_bundle_elements(self): # parsing flat bundle elements = list(parse_bundle(self.data1)) self.assertEqual(elements[0][0], self.timetag) self.assertEqual(elements[0][1], ("/test1", "i", (42, ))) self.assertEqual(elements[1][0], self.timetag) self.assertEqual(elements[1][1][:2], ("/test2", "f")) self.assertEqual(elements[2][0], self.timetag) self.assertAlmostEqual(elements[1][1][2][0], 3.141) self.assertEqual(elements[2][1], ("/test3", "s", ("hello", )))
def test_parse_bundle_elements(self): # parsing flat bundle elements = list(parse_bundle(self.data1)) self.assertEqual(elements[0][0], self.timetag) self.assertEqual(elements[0][1], ('/test1', 'i', (42, ))) self.assertEqual(elements[1][0], self.timetag) self.assertEqual(elements[1][1][:2], ('/test2', 'f')) self.assertEqual(elements[2][0], self.timetag) self.assertAlmostEqual(elements[1][1][2][0], 3.141) self.assertEqual(elements[2][1], ('/test3', 's', ('hello', )))
def test_parse_bundle_elements(self): # parsing flat bundle elements = list(parse_bundle(self.data1)) self.assertEqual(elements[0][0], self.timetag) self.assertEqual(elements[0][1], ('/test1', 'i', (42,))) self.assertEqual(elements[1][0], self.timetag) self.assertEqual(elements[1][1][:2], ('/test2', 'f')) self.assertEqual(elements[2][0], self.timetag) self.assertAlmostEqual(elements[1][1][2][0], 3.141) self.assertEqual(elements[2][1], ('/test3', 's', ('hello',)))
def test_parse_bundle_returns_generator(self): biter = parse_bundle(self.data1) self.assertTrue(isinstance(biter, typegen))
def test_parse_bundle_nobundle(self): self.assertRaises(TypeError, next, parse_bundle(b"")) self.assertRaises(TypeError, next, parse_bundle(b"/test1"))
def test_parse_bundle_nobundle(self): self.assertRaises(TypeError, next, parse_bundle(b'')) self.assertRaises(TypeError, next, parse_bundle(b'/test1'))