diff --git a/rhodecode/tests/fixture.py b/rhodecode/tests/fixture.py --- a/rhodecode/tests/fixture.py +++ b/rhodecode/tests/fixture.py @@ -26,8 +26,7 @@ import os import time import tempfile import shutil - -import configobj +import configparser from rhodecode.model.settings import SettingsModel from rhodecode.tests import * @@ -76,17 +75,20 @@ class TestINI(object): self.destroy() def create(self): - config = configobj.ConfigObj( - self.ini_file_path, file_error=True, write_empty_values=True) + parser = configparser.ConfigParser() + parser.read(self.ini_file_path) for data in self.ini_params: - section, ini_params = data.items()[0] + section, ini_params = list(data.items())[0] + for key, val in ini_params.items(): - config[section][key] = val + parser[section][key] = str(val) + with tempfile.NamedTemporaryFile( + mode='w', prefix=self.new_path_prefix, suffix='.ini', dir=self._dir, delete=False) as new_ini_file: - config.write(new_ini_file) + parser.write(new_ini_file) self.new_path = new_ini_file.name return self.new_path diff --git a/rhodecode/tests/server_utils.py b/rhodecode/tests/server_utils.py --- a/rhodecode/tests/server_utils.py +++ b/rhodecode/tests/server_utils.py @@ -24,7 +24,6 @@ import time import tempfile import pytest import subprocess -import configobj import logging from urllib.request import urlopen from urllib.error import URLError @@ -45,15 +44,15 @@ def get_port(pyramid_config): def get_host_url(pyramid_config): """Construct the host url using the port in the test configuration.""" - return '127.0.0.1:%s' % get_port(pyramid_config) + port = get_port(pyramid_config) + return f'127.0.0.1:{port}' def assert_no_running_instance(url): if is_url_reachable(url): - print("Hint: Usually this means another instance of server " - "is running in the background at %s." % url) - pytest.fail( - "Port is not free at %s, cannot start server at" % url) + print(f"Hint: Usually this means another instance of server " + f"is running in the background at {url}.") + pytest.fail(f"Port is not free at {url}, cannot start server at") class ServerBase(object): @@ -63,8 +62,10 @@ class ServerBase(object): def __init__(self, config_file, log_file): self.config_file = config_file - config_data = configobj.ConfigObj(config_file) - self._config = config_data['server:main'] + config = configparser.ConfigParser() + config.read(config_file) + + self._config = {k: v for k, v in config['server:main'].items()} self._args = [] self.log_file = log_file or os.path.join( @@ -75,7 +76,7 @@ class ServerBase(object): self.__class__.__name__, config_file)) if not os.path.isfile(config_file): - raise RuntimeError('Failed to get config at {}'.format(config_file)) + raise RuntimeError(f'Failed to get config at {config_file}') @property def command(self): diff --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -102,7 +102,7 @@ setup_requirements = ['PasteScript'] install_requirements = _get_requirements( 'requirements.txt', exclude=['setuptools', 'entrypoints']) test_requirements = _get_requirements( - 'requirements_test.txt', extras=['configobj']) + 'requirements_test.txt') def get_version():