diff options
Diffstat (limited to 'git/test')
| -rw-r--r-- | git/test/lib/helper.py | 14 | ||||
| -rw-r--r-- | git/test/test_commit.py | 13 | ||||
| -rw-r--r-- | git/test/test_git.py | 11 | ||||
| -rw-r--r-- | git/test/test_remote.py | 6 |
4 files changed, 34 insertions, 10 deletions
diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 31bee78f..541b972d 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -232,7 +232,13 @@ def with_rw_and_rw_remote_repo(working_tree_ref): prev_cwd = os.getcwd() os.chdir(rw_repo.working_dir) try: - return func(self, rw_repo, rw_remote_repo) + try: + return func(self, rw_repo, rw_remote_repo) + except: + print("Keeping repos after failure: repo_dir = %s, remote_repo_dir = %s" + % (repo_dir, remote_repo_dir), file=sys.stderr) + repo_dir = remote_repo_dir = None + raise finally: # gd.proc.kill() ... no idea why that doesn't work if gd is not None: @@ -241,8 +247,10 @@ def with_rw_and_rw_remote_repo(working_tree_ref): os.chdir(prev_cwd) rw_repo.git.clear_cache() rw_remote_repo.git.clear_cache() - shutil.rmtree(repo_dir, onerror=_rmtree_onerror) - shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror) + if repo_dir: + shutil.rmtree(repo_dir, onerror=_rmtree_onerror) + if remote_repo_dir: + shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror) if gd is not None: gd.proc.wait() diff --git a/git/test/test_commit.py b/git/test/test_commit.py index 1f0f8c56..3e958edf 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -19,15 +19,19 @@ from git import ( Actor, ) from gitdb import IStream +from gitdb.test.lib import with_rw_directory from git.compat import ( string_types, text_type ) +from git import Repo +from git.repo.fun import touch from io import BytesIO import time import sys import re +import os def assert_commit_serialization(rwrepo, commit_id, print_performance_info=False): @@ -219,6 +223,15 @@ class TestCommit(TestBase): for sha1, commit in zip(expected_ids, commits): assert_equal(sha1, commit.hexsha) + @with_rw_directory + def test_ambiguous_arg_iteration(self, rw_dir): + rw_repo = Repo.init(os.path.join(rw_dir, 'test_ambiguous_arg')) + path = os.path.join(rw_repo.working_tree_dir, 'master') + touch(path) + rw_repo.index.add([path]) + rw_repo.index.commit('initial commit') + list(rw_repo.iter_commits(rw_repo.head.ref)) # should fail unless bug is fixed + def test_count(self): assert self.rorepo.tag('refs/tags/0.1.5').commit.count() == 143 diff --git a/git/test/test_git.py b/git/test/test_git.py index 8087bc45..742c842d 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -19,6 +19,7 @@ from git.test.lib import ( from git import ( Git, GitCommandError, + GitCommandNotFound, Repo ) from gitdb.test.lib import with_rw_directory @@ -127,11 +128,7 @@ class TestGit(TestBase): def test_cmd_override(self): prev_cmd = self.git.GIT_PYTHON_GIT_EXECUTABLE - if os.name == 'nt': - exc = GitCommandError - else: - exc = OSError - # end handle windows case + exc = GitCommandNotFound try: # set it to something that doens't exist, assure it raises type(self.git).GIT_PYTHON_GIT_EXECUTABLE = os.path.join( @@ -155,6 +152,10 @@ class TestGit(TestBase): def test_change_to_transform_kwargs_does_not_break_command_options(self): self.git.log(n=1) + def test_insert_after_kwarg_raises(self): + # This isn't a complete add command, which doesn't matter here + self.failUnlessRaises(ValueError, self.git.remote, 'add', insert_kwargs_after='foo') + def test_env_vars_passed_to_git(self): editor = 'non_existant_editor' with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}): diff --git a/git/test/test_remote.py b/git/test/test_remote.py index 2540e49b..c419ecee 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -313,8 +313,7 @@ class TestRemote(TestBase): self._do_test_push_result(res, remote) # invalid refspec - res = remote.push("hellothere") - assert len(res) == 0 + self.failUnlessRaises(GitCommandError, remote.push, "hellothere") # push new tags progress = TestRemoteProgress() @@ -486,6 +485,9 @@ class TestRemote(TestBase): # END if deleted remote matches existing remote's name # END for each remote + # Issue #262 - the next call would fail if bug wasn't fixed + bare_rw_repo.create_remote('bogus', '/bogus/path', mirror='push') + def test_fetch_info(self): # assure we can handle remote-tracking branches fetch_info_line_fmt = "c437ee5deb8d00cf02f03720693e4c802e99f390 not-for-merge %s '0.3' of " |
