summaryrefslogtreecommitdiff
path: root/test/git/test_repo.py
diff options
context:
space:
mode:
authorSebastian Thiel <byronimo@gmail.com>2010-05-10 19:32:45 +0200
committerSebastian Thiel <byronimo@gmail.com>2010-05-10 19:32:51 +0200
commit837c32ba7ff2a3aa566a3b8e1330e3db0b4841d8 (patch)
treebecab82b67846625c68815aba91cd52eac3405b7 /test/git/test_repo.py
parent63761f4cb6f3017c6076ecd826ed0addcfb03061 (diff)
downloadgitpython-837c32ba7ff2a3aa566a3b8e1330e3db0b4841d8.tar.gz
repo: added test with some basic assertions for empty repositories these
repo.is_dirty: Will not fail on empty repo ( anymore ) index.entries: will just be empty if the repository is empty refs: added to_full_path method which can be used to create fully synthetic instances of Reference types, added a test for it Converted all touched files to spaces, which is why git reports so many changed files. Actually I was thinking every file would use spaces, but apparently not
Diffstat (limited to 'test/git/test_repo.py')
-rw-r--r--test/git/test_repo.py34
1 files changed, 33 insertions, 1 deletions
diff --git a/test/git/test_repo.py b/test/git/test_repo.py
index b3ce74cb..9a762bd9 100644
--- a/test/git/test_repo.py
+++ b/test/git/test_repo.py
@@ -89,7 +89,35 @@ class TestRepo(TestBase):
assert isinstance(tree, Tree)
# END for each tree
assert num_trees == mc
-
+
+
+ def _test_empty_repo(self, repo):
+ # test all kinds of things with an empty, freshly initialized repo.
+ # It should throw good errors
+
+ # entries should be empty
+ assert len(repo.index.entries) == 0
+
+ # head is accessible
+ assert repo.head
+ assert repo.head.ref
+ assert not repo.head.is_valid()
+
+ # we can change the head to some other ref
+ head_ref = Head.from_path(repo, Head.to_full_path('some_head'))
+ assert not head_ref.is_valid()
+ repo.head.ref = head_ref
+
+ # is_dirty can handle all kwargs
+ for args in ((1, 0, 0), (0, 1, 0), (0, 0, 1)):
+ assert not repo.is_dirty(*args)
+ # END for each arg
+
+ # we can add a file to the index ( if we are not bare )
+ if not repo.bare:
+ pass
+ # END test repos with working tree
+
def test_init(self):
prev_cwd = os.getcwd()
@@ -104,6 +132,8 @@ class TestRepo(TestBase):
assert isinstance(r, Repo)
assert r.bare == True
assert os.path.isdir(r.git_dir)
+
+ self._test_empty_repo(r)
shutil.rmtree(git_dir_abs)
# END for each path
@@ -111,6 +141,8 @@ class TestRepo(TestBase):
os.chdir(git_dir_rela)
r = Repo.init(bare=False)
r.bare == False
+
+ self._test_empty_repo(r)
finally:
try:
shutil.rmtree(del_dir_abs)