Move fixtures to conftest

Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
Georg Pfuetzenreuter 2023-05-21 06:03:49 +02:00
parent 8bc3173bbf
commit 1788a9cdf3
Signed by: Georg
GPG Key ID: 1ED2F138E7E6FF57
2 changed files with 28 additions and 26 deletions

27
tests/conftest.py Normal file
View File

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

View File

@ -1,33 +1,8 @@
import pytest import pytest
import os #import os
import vagrant
import dotenv 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): def test_no_arguments(script_runner, script):
result = script_runner.run(script) result = script_runner.run(script)
assert result.success is False assert result.success is False