No global variables

This commit is contained in:
Pedro Algarvio 2019-05-15 16:10:06 +01:00
parent a8c640a6c3
commit ca974fba21
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -2,16 +2,15 @@ import os
import pytest
import testinfra
if os.environ.get('KITCHEN_USERNAME') == 'vagrant':
if 'windows' in os.environ.get('KITCHEN_INSTANCE'):
test_host = testinfra.get_host('winrm://{KITCHEN_USERNAME}:{KITCHEN_PASSWORD}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}'.format(**os.environ), no_ssl=True)
else:
test_host = testinfra.get_host('paramiko://{KITCHEN_USERNAME}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}'.format(**os.environ),
ssh_identity_file=os.environ.get('KITCHEN_SSH_KEY'))
else:
test_host = testinfra.get_host('docker://{KITCHEN_USERNAME}@{KITCHEN_CONTAINER_ID}'.format(**os.environ))
@pytest.fixture
@pytest.fixture(scope='session')
def host():
return test_host
if os.environ.get('KITCHEN_USERNAME') == 'vagrant':
if 'windows' in os.environ.get('KITCHEN_INSTANCE'):
return testinfra.get_host(
'winrm://{KITCHEN_USERNAME}:{KITCHEN_PASSWORD}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}'.format(**os.environ),
no_ssl=True)
return testinfra.get_host(
'paramiko://{KITCHEN_USERNAME}@{KITCHEN_HOSTNAME}:{KITCHEN_PORT}'.format(**os.environ),
ssh_identity_file=os.environ.get('KITCHEN_SSH_KEY'))
return testinfra.get_host('docker://{KITCHEN_USERNAME}@{KITCHEN_CONTAINER_ID}'.format(**os.environ))