Isolate tests from user/system git configuration
Prevent user or system configuration from impacting the output of git commands through custom configuration options. Example is enabling of "branch.autosetuprebase=always" will result a different message being outputted by git when creating branches causing some tests to fail when attempting to match against the expected output. Change-Id: Ic6526217b598abfef0a272bc7cd1852c5821163a
This commit is contained in:
parent
f4f6674c9c
commit
f5bb6e06fd
|
@ -173,6 +173,18 @@ class BaseGitReviewTestCase(testtools.TestCase, GerritHelpers):
|
|||
# ensure user proxy conf doesn't interfere with tests
|
||||
os.environ['no_proxy'] = os.environ['NO_PROXY'] = '*'
|
||||
|
||||
# isolate tests from user and system git configuration
|
||||
self.home_dir = self._dir('site', 'tmp', 'home')
|
||||
self.xdg_config_dir = self._dir('home', '.xdgconfig')
|
||||
os.environ['HOME'] = self.home_dir
|
||||
os.environ['XDG_CONFIG_HOME'] = self.xdg_config_dir
|
||||
os.environ['GIT_CONFIG_NOSYSTEM'] = "1"
|
||||
if not os.path.exists(self.home_dir):
|
||||
os.mkdir(self.home_dir)
|
||||
if not os.path.exists(self.xdg_config_dir):
|
||||
os.mkdir(self.xdg_config_dir)
|
||||
self.addCleanup(shutil.rmtree, self.home_dir)
|
||||
|
||||
# prepare repository for the testing
|
||||
self._run_git('clone', self.project_uri)
|
||||
utils.write_to_file(self._dir('test', 'test_file.txt'),
|
||||
|
|
Loading…
Reference in New Issue