Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid a clash over temporary '.config' directory. #1871

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions gcloud/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@ def test_no_environment(self):


class Test__get_default_service_project_id(unittest2.TestCase):
temp_config_path = None
config_path = '.config/gcloud/configurations/'
config_file = 'config_default'

def setUp(self):
import tempfile
import os
self.temp_config_path = tempfile.gettempdir()

self.temp_config_path = tempfile.mkdtemp()

This comment was marked as spam.

This comment was marked as spam.


conf_path = os.path.join(self.temp_config_path, self.config_path)
os.makedirs(conf_path)
Expand All @@ -200,23 +200,20 @@ def setUp(self):
conf_file.write('[core]\nproject = test-project-id')

def tearDown(self):
import os
import shutil

if self.temp_config_path:
shutil.rmtree(os.path.join(self.temp_config_path,
'.config'))
shutil.rmtree(self.temp_config_path)

def callFUT(self, project_id=None):
from gcloud._helpers import _default_service_project_id
import os
from gcloud._helpers import _default_service_project_id
from gcloud._testing import _Monkey

def mock_expanduser(path=''):
if project_id and path.startswith('~'):
return self.temp_config_file
return ''

from gcloud._testing import _Monkey
with _Monkey(os.path, expanduser=mock_expanduser):
return _default_service_project_id()

Expand Down