Skip to content

Commit 6f03861

Browse files
committed
Add a few tests
1 parent 98a17a2 commit 6f03861

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

git/test/test_git.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,23 @@ def test_env_vars_passed_to_git(self):
153153
editor = 'non_existant_editor'
154154
with mock.patch.dict('os.environ', {'GIT_EDITOR': editor}):
155155
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() == {}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy