Browse Source

Merge "Use os.path.join as possible"

changes/41/751641/1
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
4c1cb2ea9a
6 changed files with 16 additions and 13 deletions
  1. +6
    -3
      tempest/cmd/init.py
  2. +3
    -2
      tempest/lib/cmd/skip_tracker.py
  3. +2
    -3
      tempest/lib/common/preprov_creds.py
  4. +2
    -2
      tempest/test_discover/test_discover.py
  5. +2
    -2
      tempest/tests/cmd/test_tempest_init.py
  6. +1
    -1
      tempest/tests/cmd/test_verify_tempest_config.py

+ 6
- 3
tempest/cmd/init.py View File

@@ -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])


+ 3
- 2
tempest/lib/cmd/skip_tracker.py View 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')




+ 2
- 3
tempest/lib/common/preprov_creds.py View File

@@ -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 '


+ 2
- 2
tempest/test_discover/test_discover.py View File

@@ -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))


+ 2
- 2
tempest/tests/cmd/test_tempest_init.py View File

@@ -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')


+ 1
- 1
tempest/tests/cmd/test_verify_tempest_config.py View File

@@ -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…
Cancel
Save