##// END OF EJS Templates
core: dropped usage of configobj entirely
super-admin -
r4975:0b11b7dc default
parent child Browse files
Show More
@@ -26,8 +26,7 b' import os'
26 26 import time
27 27 import tempfile
28 28 import shutil
29
30 import configobj
29 import configparser
31 30
32 31 from rhodecode.model.settings import SettingsModel
33 32 from rhodecode.tests import *
@@ -76,17 +75,20 b' class TestINI(object):'
76 75 self.destroy()
77 76
78 77 def create(self):
79 config = configobj.ConfigObj(
80 self.ini_file_path, file_error=True, write_empty_values=True)
78 parser = configparser.ConfigParser()
79 parser.read(self.ini_file_path)
81 80
82 81 for data in self.ini_params:
83 section, ini_params = data.items()[0]
82 section, ini_params = list(data.items())[0]
83
84 84 for key, val in ini_params.items():
85 config[section][key] = val
85 parser[section][key] = str(val)
86
86 87 with tempfile.NamedTemporaryFile(
88 mode='w',
87 89 prefix=self.new_path_prefix, suffix='.ini', dir=self._dir,
88 90 delete=False) as new_ini_file:
89 config.write(new_ini_file)
91 parser.write(new_ini_file)
90 92 self.new_path = new_ini_file.name
91 93
92 94 return self.new_path
@@ -24,7 +24,6 b' import time'
24 24 import tempfile
25 25 import pytest
26 26 import subprocess
27 import configobj
28 27 import logging
29 28 from urllib.request import urlopen
30 29 from urllib.error import URLError
@@ -45,15 +44,15 b' def get_port(pyramid_config):'
45 44
46 45 def get_host_url(pyramid_config):
47 46 """Construct the host url using the port in the test configuration."""
48 return '127.0.0.1:%s' % get_port(pyramid_config)
47 port = get_port(pyramid_config)
48 return f'127.0.0.1:{port}'
49 49
50 50
51 51 def assert_no_running_instance(url):
52 52 if is_url_reachable(url):
53 print("Hint: Usually this means another instance of server "
54 "is running in the background at %s." % url)
55 pytest.fail(
56 "Port is not free at %s, cannot start server at" % url)
53 print(f"Hint: Usually this means another instance of server "
54 f"is running in the background at {url}.")
55 pytest.fail(f"Port is not free at {url}, cannot start server at")
57 56
58 57
59 58 class ServerBase(object):
@@ -63,8 +62,10 b' class ServerBase(object):'
63 62
64 63 def __init__(self, config_file, log_file):
65 64 self.config_file = config_file
66 config_data = configobj.ConfigObj(config_file)
67 self._config = config_data['server:main']
65 config = configparser.ConfigParser()
66 config.read(config_file)
67
68 self._config = {k: v for k, v in config['server:main'].items()}
68 69
69 70 self._args = []
70 71 self.log_file = log_file or os.path.join(
@@ -75,7 +76,7 b' class ServerBase(object):'
75 76 self.__class__.__name__, config_file))
76 77
77 78 if not os.path.isfile(config_file):
78 raise RuntimeError('Failed to get config at {}'.format(config_file))
79 raise RuntimeError(f'Failed to get config at {config_file}')
79 80
80 81 @property
81 82 def command(self):
@@ -102,7 +102,7 b" setup_requirements = ['PasteScript']"
102 102 install_requirements = _get_requirements(
103 103 'requirements.txt', exclude=['setuptools', 'entrypoints'])
104 104 test_requirements = _get_requirements(
105 'requirements_test.txt', extras=['configobj'])
105 'requirements_test.txt')
106 106
107 107
108 108 def get_version():
General Comments 0
You need to be logged in to leave comments. Login now