From 1788a9cdf3c742fb6e7aa06d97695028a39a6655 Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sun, 21 May 2023 06:03:49 +0200 Subject: [PATCH] Move fixtures to conftest Signed-off-by: Georg Pfuetzenreuter --- tests/conftest.py | 27 +++++++++++++++++++++++++++ tests/test_cli.py | 27 +-------------------------- 2 files changed, 28 insertions(+), 26 deletions(-) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..943e0a6 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,27 @@ +import pytest +import os +import libvirt + +@pytest.fixture +def script(): + is_packaged = False + script = 'scullery' + if not is_packaged: + script = f'{script}.py' + return script + + +@pytest.fixture +def testbase(): + return os.path.abspath(os.path.dirname(os.getenv('PYTEST_CURRENT_TEST'))) + + +@pytest.fixture +def config(testbase, request): + return '{}/configs/{}.ini'.format(testbase, request.param) + + +@pytest.fixture +def virt(): + return libvirt.openReadOnly('qemu:///system') + diff --git a/tests/test_cli.py b/tests/test_cli.py index 90dbf18..2f1321b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,33 +1,8 @@ import pytest -import os -import vagrant +#import os import dotenv -import libvirt -@pytest.fixture -def script(): - is_packaged = False - script = 'scullery' - if not is_packaged: - script = f'{script}.py' - return script - - -@pytest.fixture -def testbase(): - return os.path.abspath(os.path.dirname(os.getenv('PYTEST_CURRENT_TEST'))) - - -@pytest.fixture -def config(testbase, request): - return '{}/configs/{}.ini'.format(testbase, request.param) - - -@pytest.fixture -def virt(): - return libvirt.openReadOnly('qemu:///system') - def test_no_arguments(script_runner, script): result = script_runner.run(script) assert result.success is False