[Tests] Fix PytestDeprecationWarning from pytest
Accessing pytest.config is deprecated and produces: PytestDeprecationWarning: the pytest.config global is deprecated. Please use request.config or pytest_configure (if you're a pytest plugin) instead. Fix by using a pytest.fixture
This commit is contained in:
parent
3427ae4b90
commit
742c8a941a
|
@ -19,11 +19,17 @@ from deluge.common import windows_check
|
||||||
from . import common
|
from . import common
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures('get_pytest_basetemp')
|
||||||
class DaemonBase(object):
|
class DaemonBase(object):
|
||||||
|
basetemp = None
|
||||||
|
|
||||||
if windows_check():
|
if windows_check():
|
||||||
skip = 'windows cant start_core not enough arguments for format string'
|
skip = 'windows cant start_core not enough arguments for format string'
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def get_pytest_basetemp(self, request):
|
||||||
|
self.basetemp = request.config.option.basetemp
|
||||||
|
|
||||||
def common_set_up(self):
|
def common_set_up(self):
|
||||||
common.set_tmp_config_dir()
|
common.set_tmp_config_dir()
|
||||||
self.listen_port = 58900
|
self.listen_port = 58900
|
||||||
|
@ -56,12 +62,10 @@ class DaemonBase(object):
|
||||||
|
|
||||||
# We are running py.test
|
# We are running py.test
|
||||||
if hasattr(pytest, 'config'):
|
if hasattr(pytest, 'config'):
|
||||||
# Put log file in the py.test --basetemp argument
|
if self.basetemp:
|
||||||
basetemp = pytest.config.option.basetemp
|
if not os.path.exists(self.basetemp):
|
||||||
if basetemp:
|
os.makedirs(self.basetemp)
|
||||||
if not os.path.exists(basetemp):
|
logfile = os.path.join(self.basetemp, logfile)
|
||||||
os.makedirs(basetemp)
|
|
||||||
logfile = os.path.join(basetemp, logfile)
|
|
||||||
|
|
||||||
for dummy in range(port_range):
|
for dummy in range(port_range):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue