From 690828ce2e03ce32c5a66186c543d7c5050287e4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 6 Jul 2011 22:11:48 +0200 Subject: Added basis for initial dulwich integration. Many basic issues should surface while integrating this --- git/test/db/dulwich/test_base.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 git/test/db/dulwich/test_base.py (limited to 'git/test/db/dulwich/test_base.py') diff --git a/git/test/db/dulwich/test_base.py b/git/test/db/dulwich/test_base.py new file mode 100644 index 00000000..f3489014 --- /dev/null +++ b/git/test/db/dulwich/test_base.py @@ -0,0 +1,22 @@ +# Copyright (C) 2010, 2011 Sebastian Thiel (byronimo@gmail.com) and contributors +# +# This module is part of GitDB and is released under +# the New BSD License: http://www.opensource.org/licenses/bsd-license.php +from git.test.db.base import RepoBase +from git.db.complex import PureCompatibilityGitDB + +try: + import git.db.dulwich # import test + + class TestPyDBBase(RepoBase): + + RepoCls = PureCompatibilityGitDB + + # def test_basics(self): + # pass + +except ImportError: + del(RepoBase) + import warnings + warnings.warn("Skipped all dulwich tests as they are not in the path") +#END handle import -- cgit v1.2.1 From 80aa40537a3596f24593b5a67adb6d635fe4fa22 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Jul 2011 12:55:03 +0200 Subject: Added auto-skip mixin metacls, some serious brainfuck, if the required module was not found. Its actually a nice mix between decorators which are class types, and a mixin as a metaclass, which applies said decorator. The InstanceDecorator wouldn't actually be needed, but it adds flexibility. Maybe it should be removed ... --- git/test/db/dulwich/test_base.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'git/test/db/dulwich/test_base.py') diff --git a/git/test/db/dulwich/test_base.py b/git/test/db/dulwich/test_base.py index f3489014..9bc9c394 100644 --- a/git/test/db/dulwich/test_base.py +++ b/git/test/db/dulwich/test_base.py @@ -2,21 +2,22 @@ # # 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 git.test.db.base import RepoBase from git.db.complex import PureCompatibilityGitDB try: - import git.db.dulwich # import test + import dulwich +except ImportError: + # om this case, all other dulwich tests will be skipped + pass - class TestPyDBBase(RepoBase): - - RepoCls = PureCompatibilityGitDB +class TestPyDBBase(RepoBase): + __metaclass__ = DulwichRequiredMetaMixin + RepoCls = PureCompatibilityGitDB + + @needs_dulwich_or_skip + def test_basics(self): + import dulwich + pass - # def test_basics(self): - # pass - -except ImportError: - del(RepoBase) - import warnings - warnings.warn("Skipped all dulwich tests as they are not in the path") -#END handle import -- cgit v1.2.1 From 4bb5107cff6f205f5c6e73a6f8bd22fc56f48cf4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 7 Jul 2011 14:53:37 +0200 Subject: Initial version of the DulwichType inheritance. For now, it inherits everything from the existing implementation, but one by one things can be reimplmented to use dulwich. It also shows that py 2.6 is quite plagued from its new feature, which is actually a bug, as objects inability to accept any args makes mixins hard to use ... --- git/test/db/dulwich/test_base.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'git/test/db/dulwich/test_base.py') diff --git a/git/test/db/dulwich/test_base.py b/git/test/db/dulwich/test_base.py index 9bc9c394..50e64131 100644 --- a/git/test/db/dulwich/test_base.py +++ b/git/test/db/dulwich/test_base.py @@ -3,21 +3,31 @@ # 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 git.test.lib import TestBase, with_rw_repo from git.test.db.base import RepoBase -from git.db.complex import PureCompatibilityGitDB + + try: import dulwich except ImportError: # om this case, all other dulwich tests will be skipped - pass + # Need to properly initialize the class though, otherwise it would fail + from git.db.complex import PureCompatibilityGitDB as DulwichDB +else: + # now we know dulwich is available, to do futher imports + from git.db.dulwich.complex import DulwichCompatibilityGitDB as DulwichDB + +#END handle imports class TestPyDBBase(RepoBase): __metaclass__ = DulwichRequiredMetaMixin - RepoCls = PureCompatibilityGitDB + RepoCls = DulwichDB @needs_dulwich_or_skip - def test_basics(self): - import dulwich - pass + @with_rw_repo('HEAD', bare=False) + def test_basics(self, rw_repo): + db = DulwichDB(rw_repo.working_tree_dir) + print db.git_dir + -- cgit v1.2.1