Added frame for new Repo handling and some neat decorators, including… · gitpython-developers/GitPython@bb0ac30 · GitHub
Skip to content

Commit bb0ac30

Browse files
committed
Added frame for new Repo handling and some neat decorators, including tests that test whether the testing framework does what it should
1 parent 59e2643 commit bb0ac30

4 files changed

Lines changed: 122 additions & 9 deletions

File tree

CHANGES

Lines changed: 6 additions & 0 deletions

test/git/test_base.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,13 @@
1414
from git.objects.utils import get_object_type_by_name
1515
import tempfile
1616

17-
class TestBase(object):
17+
class TestBase(TestBase):
1818

1919
type_tuples = ( ("blob", "8741fc1d09d61f02ffd8cded15ff603eff1ec070"),
2020
("tree", "3a6a5e3eeed3723c09f1ef0399f81ed6b8d82e79"),
2121
("commit", "4251bd59fb8e11e40c40548cba38180a9536118c"),
2222
("tag", "e56a60e8e9cd333cfba0140a77cd12b0d9398f10") )
2323

24-
def setup(self):
25-
self.repo = Repo(GIT_REPO)
26-
2724
def test_base_object(self):
2825
# test interface of base object classes
2926
types = (Blob, Tree, Commit, TagObject)
@@ -33,7 +30,7 @@ def test_base_object(self):
3330
num_objs = 0
3431
num_index_objs = 0
3532
for obj_type, (typename, hexsha) in zip(types, self.type_tuples):
36-
item = obj_type(self.repo,hexsha)
33+
item = obj_type(self.rorepo,hexsha)
3734
num_objs += 1
3835
assert item.id == hexsha
3936
assert item.type == typename
@@ -74,7 +71,7 @@ def test_tags(self):
7471
# tag refs can point to tag objects or to commits
7572
s = set()
7673
ref_count = 0
77-
for ref in chain(self.repo.tags, self.repo.heads):
74+
for ref in chain(self.rorepo.tags, self.rorepo.heads):
7875
ref_count += 1
7976
assert isinstance(ref, refs.Reference)
8077
assert str(ref) == ref.name
@@ -88,7 +85,7 @@ def test_tags(self):
8885

8986
def test_heads(self):
9087
# see how it dynmically updates its object
91-
for head in self.repo.heads:
88+
for head in self.rorepo.heads:
9289
head.name
9390
head.path
9491
prev_object = head.object
@@ -106,4 +103,17 @@ def test_get_object_type_by_name(self):
106103

107104
def test_object_resolution(self):
108105
# objects must be resolved to shas so they compare equal
109-
assert self.repo.head.object == self.repo.active_branch.object
106+
assert self.rorepo.head.object == self.rorepo.active_branch.object
107+
108+
@with_bare_rw_repo
109+
def test_with_bare_rw_repo(self, bare_rw_repo):
110+
assert bare_rw_repo.config_reader("repository").getboolean("core", "bare")
111+
112+
@with_rw_repo
113+
def test_with_rw_repo(self, rw_repo):
114+
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
115+
116+
@with_rw_and_rw_remote_repo
117+
def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo):
118+
assert not rw_repo.config_reader("repository").getboolean("core", "bare")
119+
assert rw_remote_repo.config_reader("repository").getboolean("core", "bare")

test/testlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from mock import *
99
from asserts import *
1010
from helper import *
11-
from unittest import TestCase
1211

1312
__all__ = [ name for name, obj in locals().items()
1413
if not (name.startswith('_') or inspect.ismodule(obj)) ]

test/testlib/helper.py

Lines changed: 98 additions & 0 deletions

0 commit comments

Comments
 (0)