Пример #1
0
    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)
Пример #2
0
    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', 0o100644, a_sha), ('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 = '0100644 foo\0' + hex_to_sha(a_sha)

        def eval_parse_tree(*args, **kwargs):
            return list(parse_tree(*args, **kwargs))

        self.assertEqual([('foo', 0o100644, a_sha)],
                          eval_parse_tree(broken_tree))
        self.assertRaises(ObjectFormatException,
                          eval_parse_tree, broken_tree, strict=True)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #5
0
 def _get_shafile_path(self, sha):
     # Check from object dir
     return hex_to_filename(self.path, sha)
Пример #6
0
 def _get_shafile_path(self, sha):
     # Check from object dir
     return hex_to_filename(self.path, sha)
Пример #7
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(os.path.dirname(__file__), 'data', base)
     return cls.from_path(hex_to_filename(dir, sha))
Пример #8
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(os.path.dirname(__file__), 'data', base)
     return cls.from_path(hex_to_filename(dir, sha))
Пример #9
0
 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())))
Пример #10
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(
         os.path.dirname(__file__.encode(sys.getfilesystemencoding())),
         b'data', base)
     return cls.from_path(hex_to_filename(dir, sha))
Пример #11
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(
         os.path.dirname(__file__.encode(sys.getfilesystemencoding())),
         b'data', base)
     return cls.from_path(hex_to_filename(dir, sha))
Пример #12
0
 def get_sha_file(self, cls, base, sha):
     dir = os.path.join(os.path.join(os.path.sep, 'tests'), 'data', base)
     return cls.from_path(hex_to_filename(dir, sha))