Move fixtures to conftest
Signed-off-by: Georg Pfuetzenreuter <mail@georg-pfuetzenreuter.net>
This commit is contained in:
parent
8bc3173bbf
commit
1788a9cdf3
27
tests/conftest.py
Normal file
27
tests/conftest.py
Normal 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')
|
||||||
|
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user