-
-
Notifications
You must be signed in to change notification settings - Fork 933
Add 'sshkey' context manager #242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1287f69
261aedd
34c0831
2a9b2f2
98a17a2
6f03861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,3 +153,23 @@ def test_env_vars_passed_to_git(self): | |
editor = 'non_existant_editor' | ||
with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}): | ||
assert self.git.var("GIT_EDITOR") == editor | ||
|
||
def test_environment(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how I could test the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something that could work is to adjust the script for the test to actually fail with a distinct error code, and possibly emit something distinctive to STDERR. |
||
# sanity check | ||
assert self.git.environment() == {} | ||
|
||
# make sure the context manager works and cleans up after itself | ||
with self.git.with_environment(PWD='/tmp'): | ||
assert self.git.environment() == {'PWD': '/tmp'} | ||
|
||
assert self.git.environment() == {} | ||
|
||
old_env = self.git.update_environment(VARKEY='VARVALUE') | ||
# The returned dict can be used to revert the change, hence why it has | ||
# an entry with value 'None'. | ||
assert old_env == {'VARKEY': None} | ||
assert self.git.environment() == {'VARKEY': 'VARVALUE'} | ||
|
||
new_env = self.git.update_environment(**old_env) | ||
assert new_env == {'VARKEY': 'VARVALUE'} | ||
assert self.git.environment() == {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env python | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Possibly the MANIFEST.in file needs adjustment to assure this file also gets distributed when making new releases through setuptools. |
||
|
||
import os | ||
import subprocess | ||
import sys | ||
|
||
ssh_options = ['-i', os.environ['GIT_SSH_KEY_FILE']] | ||
ret_code = subprocess.call(['ssh'] + ssh_options + sys.argv[1:]) | ||
sys.exit(ret_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a moment I thought this method is to specific, but on the other hand, it makes setting ssh-keys (by using key-files) really easy.
Therefore the only thing I will do is see how this works on windows, and possibly put in an assertion to run on non-windows systems only.