diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2010-02-19 16:52:38 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2010-02-19 17:54:30 +0100 |
commit | f96ee7463e2454e95bf0d77ca4fe5107d3f24d68 (patch) | |
tree | 49f0deaa7221f5a259a0943b26b65dd2c2316f85 /test/testlib/helper.py | |
parent | 76fd1d4119246e2958c571d1f64c5beb88a70bd4 (diff) | |
download | gitpython-f96ee7463e2454e95bf0d77ca4fe5107d3f24d68.tar.gz |
index: added move method including test
test.helpers: temporary rw repository creators now set the working dir of the program, easing working with relative paths a lot
Diffstat (limited to 'test/testlib/helper.py')
-rw-r--r-- | test/testlib/helper.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/testlib/helper.py b/test/testlib/helper.py index da4a4207..ba748a15 100644 --- a/test/testlib/helper.py +++ b/test/testlib/helper.py @@ -90,6 +90,7 @@ def with_bare_rw_repo(func): def bare_repo_creator(self): repo_dir = tempfile.mktemp("bare_repo") rw_repo = self.rorepo.clone(repo_dir, shared=True, bare=True) + prev_cwd = os.getcwd() try: return func(self, rw_repo) finally: @@ -106,6 +107,9 @@ def with_rw_repo(working_tree_ref): out the working tree at the given working_tree_ref. This repository type is more costly due to the working copy checkout. + + To make working with relative paths easier, the cwd will be set to the working + dir of the repository. """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" def argument_passer(func): @@ -116,9 +120,12 @@ def with_rw_repo(working_tree_ref): rw_repo.head.commit = working_tree_ref rw_repo.head.reference.checkout() + prev_cwd = os.getcwd() + os.chdir(rw_repo.working_dir) try: return func(self, rw_repo) finally: + os.chdir(prev_cwd) rw_repo.git.clear_cache() shutil.rmtree(repo_dir, onerror=_rmtree_onerror) # END cleanup @@ -148,6 +155,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): def case(self, rw_repo, rw_remote_repo) This setup allows you to test push and pull scenarios and hooks nicely. + + See working dir info in with_rw_repo """ assert isinstance(working_tree_ref, basestring), "Decorator requires ref name for working tree checkout" def argument_passer(func): @@ -192,9 +201,13 @@ def with_rw_and_rw_remote_repo(working_tree_ref): else: raise AssertionError('Please start a git-daemon to run this test, execute: git-daemon "%s"'%tempfile.gettempdir()) + # adjust working dir + prev_cwd = os.getcwd() + os.chdir(rw_repo.working_dir) try: return func(self, rw_repo, rw_remote_repo) finally: + os.chdir(prev_cwd) rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() shutil.rmtree(repo_dir, onerror=_rmtree_onerror) |