Use os.path.join as possible
This commit makes to use os.path.join instead of using the Unix path character '/'. This change is not mandatory since we don't support Windows environments as Tempest execution and, it seems Windows supports '/' as a path separator. However, using both os.path.join and '/' is a bit awkward. Change-Id: I117acb281c352179d526808009e761335bb314fc
This commit is contained in:
parent
b666f90498
commit
9e492eee81
@ -44,11 +44,14 @@ def get_tempest_default_config_dir():
|
||||
|
||||
:return: default config dir
|
||||
"""
|
||||
# NOTE: The default directory should be on a Linux box.
|
||||
global_conf_dir = '/etc/tempest'
|
||||
xdg_config = os.environ.get('XDG_CONFIG_HOME',
|
||||
os.path.expanduser('~/.config'))
|
||||
os.path.expanduser(os.path.join('~',
|
||||
'.config')))
|
||||
user_xdg_global_path = os.path.join(xdg_config, 'tempest')
|
||||
user_global_path = os.path.join(os.path.expanduser('~'), '.tempest/etc')
|
||||
user_global_path = os.path.join(os.path.expanduser('~'),
|
||||
'.tempest', 'etc')
|
||||
if os.path.isdir(global_conf_dir):
|
||||
return global_conf_dir
|
||||
elif os.path.isdir(user_xdg_global_path):
|
||||
@ -121,7 +124,7 @@ class TempestInit(command.Command):
|
||||
def generate_sample_config(self, local_dir):
|
||||
conf_generator = os.path.join(os.path.dirname(__file__),
|
||||
'config-generator.tempest.conf')
|
||||
output_file = os.path.join(local_dir, 'etc/tempest.conf.sample')
|
||||
output_file = os.path.join(local_dir, 'etc', 'tempest.conf.sample')
|
||||
if os.path.isfile(conf_generator):
|
||||
generator.main(['--config-file', conf_generator, '--output-file',
|
||||
output_file])
|
||||
|
@ -31,10 +31,11 @@ try:
|
||||
except ImportError:
|
||||
launchpad = None
|
||||
|
||||
LPCACHEDIR = os.path.expanduser('~/.launchpadlib/cache')
|
||||
LPCACHEDIR = os.path.expanduser(os.path.join('~', '.launchpadlib', 'cache'))
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../..'))
|
||||
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..', '..', '..'))
|
||||
TESTDIR = os.path.join(BASEDIR, 'tempest')
|
||||
|
||||
|
||||
|
@ -172,7 +172,7 @@ class PreProvisionedCredentialProvider(cred_provider.CredentialProvider):
|
||||
return self.is_multi_user()
|
||||
|
||||
def _create_hash_file(self, hash_string):
|
||||
path = os.path.join(os.path.join(self.accounts_dir, hash_string))
|
||||
path = os.path.join(self.accounts_dir, hash_string)
|
||||
if not os.path.isfile(path):
|
||||
with open(path, 'w') as fd:
|
||||
fd.write(self.name)
|
||||
@ -194,8 +194,7 @@ class PreProvisionedCredentialProvider(cred_provider.CredentialProvider):
|
||||
if res:
|
||||
return _hash
|
||||
else:
|
||||
path = os.path.join(os.path.join(self.accounts_dir,
|
||||
_hash))
|
||||
path = os.path.join(self.accounts_dir, _hash)
|
||||
with open(path, 'r') as fd:
|
||||
names.append(fd.read())
|
||||
msg = ('Insufficient number of users provided. %s have allocated all '
|
||||
|
@ -30,8 +30,8 @@ def load_tests(loader, tests, pattern):
|
||||
base_path = os.path.split(os.path.dirname(os.path.abspath(__file__)))[0]
|
||||
base_path = os.path.split(base_path)[0]
|
||||
# Load local tempest tests
|
||||
for test_dir in ['tempest/api', 'tempest/scenario']:
|
||||
full_test_dir = os.path.join(base_path, test_dir)
|
||||
for test_dir in ['api', 'scenario']:
|
||||
full_test_dir = os.path.join(base_path, 'tempest', test_dir)
|
||||
if not pattern:
|
||||
suite.addTests(loader.discover(full_test_dir,
|
||||
top_level_dir=base_path))
|
||||
|
@ -40,7 +40,7 @@ class TestTempestInit(base.TestCase):
|
||||
|
||||
def test_generate_sample_config(self):
|
||||
local_dir = self.useFixture(fixtures.TempDir())
|
||||
etc_dir_path = os.path.join(local_dir.path, 'etc/')
|
||||
etc_dir_path = os.path.join(local_dir.path, 'etc')
|
||||
os.mkdir(etc_dir_path)
|
||||
init_cmd = init.TempestInit(None, None)
|
||||
local_sample_conf_file = os.path.join(etc_dir_path,
|
||||
@ -56,7 +56,7 @@ class TestTempestInit(base.TestCase):
|
||||
|
||||
def test_update_local_conf(self):
|
||||
local_dir = self.useFixture(fixtures.TempDir())
|
||||
etc_dir_path = os.path.join(local_dir.path, 'etc/')
|
||||
etc_dir_path = os.path.join(local_dir.path, 'etc')
|
||||
os.mkdir(etc_dir_path)
|
||||
lock_dir = os.path.join(local_dir.path, 'tempest_lock')
|
||||
config_path = os.path.join(etc_dir_path, 'tempest.conf')
|
||||
|
@ -579,7 +579,7 @@ class TestDiscovery(base.TestCase):
|
||||
os, 'fakeservice')
|
||||
|
||||
def test_get_config_file(self):
|
||||
conf_dir = os.path.join(os.getcwd(), 'etc/')
|
||||
conf_dir = os.path.join(os.getcwd(), 'etc')
|
||||
conf_file = "tempest.conf.sample"
|
||||
local_sample_conf_file = os.path.join(conf_dir, conf_file)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user