From 8df6b87a793434065cd9a01fcaa812e3ea47c4dd Mon Sep 17 00:00:00 2001 From: Darragh Bailey Date: Mon, 17 Nov 2014 15:58:04 +0000 Subject: Copy environment for subprocess execution Git utilizes multiple environment variables to control various behaviours. Make sure to set LC_MESSAGES on a copy of the environment instead of discarding any variables that may be set by the user or default shell environment such as EDITOR. Add test to assert that when overriding GIT_EDITOR via os.environ that the modified value will be picked up by and git commands called. --- git/test/test_git.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'git/test/test_git.py') diff --git a/git/test/test_git.py b/git/test/test_git.py index 49c256ca..063a4d38 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -5,6 +5,7 @@ # the BSD License: http://www.opensource.org/licenses/bsd-license.php import os +import mock from git.test.lib import (TestBase, patch, raises, @@ -128,3 +129,8 @@ class TestGit(TestBase): def test_change_to_transform_kwargs_does_not_break_command_options(self): self.git.log(n=1) + + 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 -- cgit v1.2.1