summaryrefslogtreecommitdiff
path: root/git
diff options
context:
space:
mode:
authorJonas Trappenberg <jonas@trappenberg.ch>2015-01-21 22:26:59 -0800
committerJonas Trappenberg <jonas@trappenberg.ch>2015-01-21 22:26:59 -0800
commit6f038611ff120f8283f0f1a56962f95b66730c72 (patch)
tree51167060262be5753abf7bcee73afe31a3911c8d /git
parent98a17a28a21fe5f06dd2da561839fdbaa1912c64 (diff)
downloadgitpython-6f038611ff120f8283f0f1a56962f95b66730c72.tar.gz
Add a few tests
Diffstat (limited to 'git')
-rw-r--r--git/test/test_git.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/git/test/test_git.py b/git/test/test_git.py
index f25fa21a..85ee56c6 100644
--- a/git/test/test_git.py
+++ b/git/test/test_git.py
@@ -153,3 +153,23 @@ class TestGit(TestBase):
editor = 'non_existant_editor'
with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}):
assert self.git.var("GIT_EDITOR") == editor
+
+ def test_environment(self):
+ # 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() == {}