From ca974fba21212c2aa6cc2983a319a5d068065b98 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Wed, 15 May 2019 16:10:06 +0100 Subject: [PATCH] No global variables --- tests/conftest.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 6dadeb5..07c2ab9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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))