@@ -181,14 +181,14 @@ def test_no_environment(self):
181181
182182
183183class Test__get_default_service_project_id (unittest2 .TestCase ):
184- temp_config_path = None
185184 config_path = '.config/gcloud/configurations/'
186185 config_file = 'config_default'
187186
188187 def setUp (self ):
189188 import tempfile
190189 import os
191- self .temp_config_path = tempfile .gettempdir ()
190+
191+ self .temp_config_path = tempfile .mkdtemp ()
192192
193193 conf_path = os .path .join (self .temp_config_path , self .config_path )
194194 os .makedirs (conf_path )
@@ -200,23 +200,20 @@ def setUp(self):
200200 conf_file .write ('[core]\n project = test-project-id' )
201201
202202 def tearDown (self ):
203- import os
204203 import shutil
205204
206- if self .temp_config_path :
207- shutil .rmtree (os .path .join (self .temp_config_path ,
208- '.config' ))
205+ shutil .rmtree (self .temp_config_path )
209206
210207 def callFUT (self , project_id = None ):
211- from gcloud ._helpers import _default_service_project_id
212208 import os
209+ from gcloud ._helpers import _default_service_project_id
210+ from gcloud ._testing import _Monkey
213211
214212 def mock_expanduser (path = '' ):
215213 if project_id and path .startswith ('~' ):
216214 return self .temp_config_file
217215 return ''
218216
219- from gcloud ._testing import _Monkey
220217 with _Monkey (os .path , expanduser = mock_expanduser ):
221218 return _default_service_project_id ()
222219
0 commit comments