diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-22 16:45:12 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-22 16:45:12 +0100 |
commit | 0ddbe4bc24e634e6496abd3bc6ce3c4377cdf2fb (patch) | |
tree | 3fea2f99d9108cddc99d87ec834ad176b486bd5b /git/test/test_git.py | |
parent | 5ad07f7b23e762e3eb99ce45020375d2bd743fc5 (diff) | |
download | gitpython-0ddbe4bc24e634e6496abd3bc6ce3c4377cdf2fb.tar.gz |
Added test for `sshkey` context manager.
It verifies that the script is actually called.
Interestingly, the shell script version works within an msysgit environment
on windows.
Fixes #234
Diffstat (limited to 'git/test/test_git.py')
-rw-r--r-- | git/test/test_git.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/git/test/test_git.py b/git/test/test_git.py index 990f4cd0..18acd77e 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -181,11 +181,26 @@ class TestGit(TestBase): assert new_env == {'VARKEY': 'VARVALUE'} assert self.git.environment() == {} - rw_repo = Repo.init(os.path.join(rw_dir, 'repo')) + class TestRepo(Repo): + class GitCommandWrapperType(Git): + def _sshkey_script_path(self): + path = os.path.join(rw_dir, 'failing-script.sh') + stream = open(path, 'wt') + stream.write("#!/usr/bin/env sh\n" + + "echo FOO\n") + stream.close() + os.chmod(path, 0o555) + return path + # end Git + # end Repo + + rw_repo = TestRepo.init(os.path.join(rw_dir, 'repo')) remote = rw_repo.create_remote('ssh-origin', "ssh://git@server/foo") with rw_repo.git.sshkey('doesntexist.key'): - remote.fetch() + try: + remote.fetch() + except GitCommandError as err: + assert 'FOO' in str(err) + # end # end - - |