Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 58 lines (46 sloc) 1.976 kb
f09a02a @jdavid Use UTF-8 encoding in all Python files
jdavid authored
1 # -*- coding: UTF-8 -*-
33d775a @dborowitz Add Blob class.
dborowitz authored
2 #
3 # Copyright 2010 Google, Inc.
4 #
5 # This file is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2,
7 # as published by the Free Software Foundation.
8 #
9 # In addition to the permissions in the GNU General Public License,
10 # the authors give you unlimited permission to link the compiled
11 # version of this file into combinations with other programs,
12 # and to distribute those combinations without any restriction
13 # coming from the use of this file. (The General Public License
14 # restrictions do apply in other respects; for example, they cover
15 # modification of the file, and distribution when not linked into
16 # a combined executable.)
17 #
18 # This file is distributed in the hope that it will be useful, but
19 # WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 # General Public License for more details.
22 #
23 # You should have received a copy of the GNU General Public License
24 # along with this program; see the file COPYING. If not, write to
25 # the Free Software Foundation, 51 Franklin Street, Fifth Floor,
26 # Boston, MA 02110-1301, USA.
27
28 """Tests for Blob objects."""
29
b84b79a @jdavid Fix running the tests with Python 3
jdavid authored
30 from __future__ import absolute_import
7950ee1 Use Python 3 string literals for the unit tests
J. David Ibáñez authored
31 from __future__ import unicode_literals
33d775a @dborowitz Add Blob class.
dborowitz authored
32 import unittest
33
34 import pygit2
b84b79a @jdavid Fix running the tests with Python 3
jdavid authored
35 from . import utils
33d775a @dborowitz Add Blob class.
dborowitz authored
36
7950ee1 Use Python 3 string literals for the unit tests
J. David Ibáñez authored
37
38 __author__ = 'dborowitz@google.com (Dave Borowitz)'
39
33d775a @dborowitz Add Blob class.
dborowitz authored
40 BLOB_SHA = 'af431f20fc541ed6d5afede3e2dc7160f6f01f16'
41
42
fe1540f Add index test case for a non-bare repo
J. David Ibañez authored
43 class BlobTest(utils.BareRepoTestCase):
33d775a @dborowitz Add Blob class.
dborowitz authored
44
45 def test_read_blob(self):
46 blob = self.repo[BLOB_SHA]
83642a6 @jdavid Rename '.sha' to '.hex'
jdavid authored
47 self.assertEqual(blob.hex, BLOB_SHA)
e9e902e @jdavid tests: add utility function 'oid_to_hex'
jdavid authored
48 sha = utils.oid_to_hex(blob.oid)
11ff184 @jdavid Add Object.oid to get the raw object id
jdavid authored
49 self.assertEqual(sha, BLOB_SHA)
33d775a @dborowitz Add Blob class.
dborowitz authored
50 self.assertTrue(isinstance(blob, pygit2.Blob))
51 self.assertEqual(pygit2.GIT_OBJ_BLOB, blob.type)
7f65680 Fix blob unit tests
J. David Ibáñez authored
52 self.assertEqual(b'a contents\n', blob.data)
53 self.assertEqual(b'a contents\n', blob.read_raw())
33d775a @dborowitz Add Blob class.
dborowitz authored
54
55
56 if __name__ == '__main__':
fd5aab4 @jdavid tests: minor coding style fix, use 4 spaces indent
jdavid authored
57 unittest.main()
Something went wrong with that request. Please try again.