def _do_test_parse_tree(self, parse_tree): dir = os.path.join(os.path.dirname(__file__), "data", "trees") o = Tree.from_path(hex_to_filename(dir, tree_sha)) self.assertEqual([("a", 0100644, a_sha), ("b", 0100644, b_sha)], list(parse_tree(o.as_raw_string()))) # test a broken tree that has a leading 0 on the file mode broken_tree = "0100644 foo\0" + hex_to_sha(a_sha) def eval_parse_tree(*args, **kwargs): return list(parse_tree(*args, **kwargs)) self.assertEqual([("foo", 0100644, a_sha)], eval_parse_tree(broken_tree)) self.assertRaises(ObjectFormatException, eval_parse_tree, broken_tree, strict=True)
def _do_test_parse_tree(self, parse_tree): dir = os.path.join(os.path.join(os.path.sep, 'tests'), 'data', 'trees') o = Tree.from_path(hex_to_filename(dir, tree_sha)) self.assertEquals([('a', 0100644, a_sha), ('b', 0100644, b_sha)], list(parse_tree(o.as_raw_string()))) # test a broken tree that has a leading 0 on the file mode broken_tree = '0100644 foo\0' + hex_to_sha(a_sha) def eval_parse_tree(*args, **kwargs): return list(parse_tree(*args, **kwargs)) self.assertEquals([('foo', 0100644, a_sha)], eval_parse_tree(broken_tree)) self.assertRaises(ObjectFormatException, eval_parse_tree, broken_tree, strict=True)
def _do_test_parse_tree(self, parse_tree): dir = os.path.join( os.path.dirname(__file__.encode(sys.getfilesystemencoding())), b'data', b'trees') o = Tree.from_path(hex_to_filename(dir, tree_sha)) self.assertEqual([(b'a', 0o100644, a_sha), (b'b', 0o100644, b_sha)], list(parse_tree(o.as_raw_string()))) # test a broken tree that has a leading 0 on the file mode broken_tree = b'0100644 foo\0' + hex_to_sha(a_sha) def eval_parse_tree(*args, **kwargs): return list(parse_tree(*args, **kwargs)) self.assertEqual([(b'foo', 0o100644, a_sha)], eval_parse_tree(broken_tree)) self.assertRaises(ObjectFormatException, eval_parse_tree, broken_tree, strict=True)
def eval_parse_tree(*args, **kwargs): return list(parse_tree(*args, **kwargs))
def _do_test_parse_tree(self, parse_tree): dir = os.path.join(os.path.dirname(__file__), 'data', 'trees') o = Tree.from_path(hex_to_filename(dir, tree_sha)) self.assertEquals([('a', 0100644, a_sha), ('b', 0100644, b_sha)], list(parse_tree(o.as_raw_string())))