summaryrefslogtreecommitdiff
path: root/gitdb/test/db/test_git.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2014-11-14 12:45:19 +0100
committerSebastian Thiel <byronimo@gmail.com>2014-11-14 12:45:19 +0100
commit2f2fe4eea8ba4f47e63a7392a1f27f74f5ee925d (patch)
tree176a493d114fab7cc6e930bf318b2339db386cf5 /gitdb/test/db/test_git.py
parent81707c606b88e971cc359e3e9f3abeeea2204860 (diff)
parent0dcec5a27b341ce58e5ab169f91aa25b2cafec0c (diff)
downloadgitdb-0.6.0.tar.gz
Merge branch 'py2n3'0.6.0
* python 3 compatibility * all tests work in py2.6, 2.7, 3.3, 3.4
Diffstat (limited to 'gitdb/test/db/test_git.py')
-rw-r--r--gitdb/test/db/test_git.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/gitdb/test/db/test_git.py b/gitdb/test/db/test_git.py
index 1ef577a..e141c2b 100644
--- a/gitdb/test/db/test_git.py
+++ b/gitdb/test/db/test_git.py
@@ -2,46 +2,51 @@
#
# This module is part of GitDB and is released under
# the New BSD License: http://www.opensource.org/licenses/bsd-license.php
-from lib import *
+from gitdb.test.db.lib import (
+ TestDBBase,
+ fixture_path,
+ with_rw_directory
+)
from gitdb.exc import BadObject
from gitdb.db import GitDB
from gitdb.base import OStream, OInfo
from gitdb.util import hex_to_bin, bin_to_hex
-
+
class TestGitDB(TestDBBase):
-
+
def test_reading(self):
gdb = GitDB(fixture_path('../../../.git/objects'))
-
+
# we have packs and loose objects, alternates doesn't necessarily exist
assert 1 < len(gdb.databases()) < 4
-
+
# access should be possible
gitdb_sha = hex_to_bin("5690fd0d3304f378754b23b098bd7cb5f4aa1976")
assert isinstance(gdb.info(gitdb_sha), OInfo)
assert isinstance(gdb.stream(gitdb_sha), OStream)
- assert gdb.size() > 200
+ ni = 50
+ assert gdb.size() >= ni
sha_list = list(gdb.sha_iter())
assert len(sha_list) == gdb.size()
-
-
- # This is actually a test for compound functionality, but it doesn't
+ sha_list = sha_list[:ni] # speed up tests ...
+
+
+ # This is actually a test for compound functionality, but it doesn't
# have a separate test module
# test partial shas
# this one as uneven and quite short
assert gdb.partial_to_complete_sha_hex('155b6') == hex_to_bin("155b62a9af0aa7677078331e111d0f7aa6eb4afc")
-
+
# mix even/uneven hexshas
for i, binsha in enumerate(sha_list):
assert gdb.partial_to_complete_sha_hex(bin_to_hex(binsha)[:8-(i%2)]) == binsha
# END for each sha
-
+
self.failUnlessRaises(BadObject, gdb.partial_to_complete_sha_hex, "0000")
-
+
@with_rw_directory
def test_writing(self, path):
gdb = GitDB(path)
-
+
# its possible to write objects
self._assert_object_writing(gdb)
- self._assert_object_writing_async(gdb)