File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -153,3 +153,23 @@ def test_env_vars_passed_to_git(self):
153
153
editor = 'non_existant_editor'
154
154
with mock .patch .dict ('os.environ' , {'GIT_EDITOR' : editor }):
155
155
assert self .git .var ("GIT_EDITOR" ) == editor
156
+
157
+ def test_environment (self ):
158
+ # sanity check
159
+ assert self .git .environment () == {}
160
+
161
+ # make sure the context manager works and cleans up after itself
162
+ with self .git .with_environment (PWD = '/tmp' ):
163
+ assert self .git .environment () == {'PWD' : '/tmp' }
164
+
165
+ assert self .git .environment () == {}
166
+
167
+ old_env = self .git .update_environment (VARKEY = 'VARVALUE' )
168
+ # The returned dict can be used to revert the change, hence why it has
169
+ # an entry with value 'None'.
170
+ assert old_env == {'VARKEY' : None }
171
+ assert self .git .environment () == {'VARKEY' : 'VARVALUE' }
172
+
173
+ new_env = self .git .update_environment (** old_env )
174
+ assert new_env == {'VARKEY' : 'VARVALUE' }
175
+ assert self .git .environment () == {}
You can’t perform that action at this time.
0 commit comments