diff options
author | bendikro <bro.devel+deluge@gmail.com> | 2019-10-25 00:05:21 +0200 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2020-04-23 17:19:37 +0100 |
commit | 742c8a941af6691a6e48b167a70d15fdd5546924 (patch) | |
tree | 2b0d136c15814f9c6197141531fb22283baf6646 | |
parent | 3427ae4b9079b4f1ae65e1203913bd8215247617 (diff) | |
download | deluge-742c8a941af6691a6e48b167a70d15fdd5546924.tar.gz deluge-742c8a941af6691a6e48b167a70d15fdd5546924.tar.bz2 deluge-742c8a941af6691a6e48b167a70d15fdd5546924.zip |
[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
-rw-r--r-- | deluge/tests/daemon_base.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/deluge/tests/daemon_base.py b/deluge/tests/daemon_base.py index eda2193e9..7352e0d32 100644 --- a/deluge/tests/daemon_base.py +++ b/deluge/tests/daemon_base.py @@ -19,11 +19,17 @@ from deluge.common import windows_check from . import common +@pytest.mark.usefixtures('get_pytest_basetemp') class DaemonBase(object): + basetemp = None if windows_check(): 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): common.set_tmp_config_dir() self.listen_port = 58900 @@ -56,12 +62,10 @@ class DaemonBase(object): # We are running py.test if hasattr(pytest, 'config'): - # Put log file in the py.test --basetemp argument - basetemp = pytest.config.option.basetemp - if basetemp: - if not os.path.exists(basetemp): - os.makedirs(basetemp) - logfile = os.path.join(basetemp, logfile) + if self.basetemp: + if not os.path.exists(self.basetemp): + os.makedirs(self.basetemp) + logfile = os.path.join(self.basetemp, logfile) for dummy in range(port_range): try: |