def test_generate_path_leaves(self): data = open(DATA, 'rb').read() nodes, bits = PathTree._unpack_data(data) ret = PathTree._generate_path_leaves(GhettoBitStream(bits)) self.assertEqual(len(ret), 4) for node in ret: self.assertTrue(isinstance(node, HuffmanNode))
def test_generate_path_leaves(self): data = open(DATA).read() nodes, bits = PathTree._unpack_data(data) ret = PathTree._generate_path_leaves(GhettoBitStream(bits)) self.assertEqual(len(ret), 4) for node in ret: self.assertTrue(isinstance(node, HuffmanNode))
def test_unpack_data(self): data = open(DATA, 'rb').read() nodes, bits = PathTree._unpack_data(data) self.assertEqual(len(nodes), 6) # first node always gets weight of 1 self.assertEqual(nodes[0].weight, 1) self.assertEqual(nodes[0].value, 'never') self.assertEqual(nodes[5].weight, 6) self.assertEqual(nodes[5].value, '') self.assertEqual(len(bits), 6)
def test_unpack_data(self): data = open(DATA).read() nodes, bits = PathTree._unpack_data(data) self.assertEqual(len(nodes), 6) # first node always gets weight of 1 self.assertEqual(nodes[0].weight, 1) self.assertEqual(nodes[0].value, 'never') self.assertEqual(nodes[5].weight, 6) self.assertEqual(nodes[5].value, '') self.assertEqual(len(bits), 6)