From 7fab60c596cdd2588f9c7b2b4eb9f93f8736b915 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Mon, 30 May 2011 20:10:47 +0200 Subject: Fixed all of the object tests, except for the submodule handling which needs more work as the amount of submodules changed in fact. Maybe I should just generate a test repository with gitpython as submodule to get the recursion depth required to satisfy the test --- git/test/objects/lib.py | 18 ++++++++++++++++++ git/test/objects/test_blob.py | 6 +++--- git/test/objects/test_commit.py | 14 +++++++++----- git/test/objects/test_submodule.py | 5 +++-- git/test/objects/test_tree.py | 10 ++++++---- 5 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 git/test/objects/lib.py (limited to 'git/test') diff --git a/git/test/objects/lib.py b/git/test/objects/lib.py new file mode 100644 index 00000000..c146833d --- /dev/null +++ b/git/test/objects/lib.py @@ -0,0 +1,18 @@ +"""Provide customized obhject testing facilities""" + +from git.test.lib import ( + rorepo_dir, + TestBase, + assert_equal, + assert_not_equal, + with_rw_repo, + StringProcessAdapter, + ) +from git.repo import Repo + +class TestObjectBase(TestBase): + """Provides a default read-only repository in the rorepo member""" + + @classmethod + def setUpAll(cls): + cls.rorepo = Repo(rorepo_dir()) diff --git a/git/test/objects/test_blob.py b/git/test/objects/test_blob.py index a6de7fb7..58ac25b7 100644 --- a/git/test/objects/test_blob.py +++ b/git/test/objects/test_blob.py @@ -4,11 +4,11 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.test.lib import TestBase -from git import * +from lib import * +from git.objects.blob import * from git.util import hex_to_bin -class TestBlob(TestBase): +class TestBlob(TestObjectBase): def test_mime_type_should_return_mime_type_for_known_types(self): blob = Blob(self.rorepo, **{'binsha': Blob.NULL_BIN_SHA, 'path': 'foo.png'}) diff --git a/git/test/objects/test_commit.py b/git/test/objects/test_commit.py index 3ccff228..80326fe9 100644 --- a/git/test/objects/test_commit.py +++ b/git/test/objects/test_commit.py @@ -5,10 +5,14 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.test.lib import TestBase -from git import * -from git import IStream -from git.util import hex_to_bin +from lib import * +from git.objects.commit import * +from git.base import IStream + +from git.util import ( + hex_to_bin, + Actor, + ) from cStringIO import StringIO import time @@ -65,7 +69,7 @@ def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False) # END handle performance info -class TestCommit(TestBase): +class TestCommit(TestObjectBase): def test_bake(self): diff --git a/git/test/objects/test_submodule.py b/git/test/objects/test_submodule.py index cb5fd33f..b3405a96 100644 --- a/git/test/objects/test_submodule.py +++ b/git/test/objects/test_submodule.py @@ -1,11 +1,12 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from git.test.lib import TestBase +from lib import * from git.exc import * from git.objects.submodule.base import Submodule from git.objects.submodule.root import RootModule, RootUpdateProgress from git.util import to_native_path_linux, join_path_native + import shutil import git import os @@ -18,7 +19,7 @@ class TestRootProgress(RootUpdateProgress): prog = TestRootProgress() -class TestSubmodule(TestBase): +class TestSubmodule(TestObjectBase): k_subm_current = "468cad66ff1f80ddaeee4123c24e4d53a032c00d" k_subm_changed = "394ed7006ee5dc8bddfd132b64001d5dfc0ffdd3" diff --git a/git/test/objects/test_tree.py b/git/test/objects/test_tree.py index af32aeb9..bc8d3f97 100644 --- a/git/test/objects/test_tree.py +++ b/git/test/objects/test_tree.py @@ -4,16 +4,18 @@ # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -import os -from git.test.lib import TestBase -from git import * + +from lib import * from git.objects.fun import ( traverse_tree_recursive, traverse_trees_recursive ) +from git.objects.blob import Blob +from git.objects.tree import Tree from cStringIO import StringIO +import os -class TestTree(TestBase): +class TestTree(TestObjectBase): def test_serializable(self): # tree at the given commit contains a submodule as well -- cgit v1.2.3