Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 964
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1287f69261aedd34c08312a9b2f298a17a26f03861File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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): | ||
ContributorAuthor 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 Member 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 | ||
Member 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. | ||
| importos | ||
| importsubprocess | ||
| importsys | ||
| 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.