Skip to content

Commit e2f1fd8

Browse files
committed
test: use f-strings in feature_config_args.py
1 parent 36d33d3 commit e2f1fd8

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test/functional/feature_config_args.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_config_file_parser(self):
2424

2525
inc_conf_file_path = os.path.join(self.nodes[0].datadir, 'include.conf')
2626
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
27-
conf.write('includeconf={}\n'.format(inc_conf_file_path))
27+
conf.write(f'includeconf={inc_conf_file_path}\n')
2828

2929
self.nodes[0].assert_start_raises_init_error(
3030
expected_msg='Error: Error parsing command line arguments: Invalid parameter -dash_cli=1',
@@ -43,13 +43,13 @@ def test_config_file_parser(self):
4343
if self.is_wallet_compiled():
4444
with open(inc_conf_file_path, 'w', encoding='utf8') as conf:
4545
conf.write("wallet=foo\n")
46-
self.nodes[0].assert_start_raises_init_error(expected_msg='Error: Config setting for -wallet only applied on %s network when in [%s] section.' % (self.chain, self.chain))
46+
self.nodes[0].assert_start_raises_init_error(expected_msg=f'Error: Config setting for -wallet only applied on {self.chain} network when in [{self.chain}] section.')
4747

4848
main_conf_file_path = os.path.join(self.options.tmpdir, 'node0', 'bitcoin_main.conf')
49-
util.write_config(main_conf_file_path, n=0, chain='', extra_config='includeconf={}\n'.format(inc_conf_file_path))
49+
util.write_config(main_conf_file_path, n=0, chain='', extra_config=f'includeconf={inc_conf_file_path}\n')
5050
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
5151
conf.write('acceptnonstdtxn=1\n')
52-
self.nodes[0].assert_start_raises_init_error(extra_args=["-conf={}".format(main_conf_file_path)], expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
52+
self.nodes[0].assert_start_raises_init_error(extra_args=[f"-conf={main_conf_file_path}"], expected_msg='Error: acceptnonstdtxn is not currently supported for main chain')
5353

5454
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
5555
conf.write('nono\n')
@@ -69,14 +69,14 @@ def test_config_file_parser(self):
6969

7070
inc_conf_file2_path = os.path.join(self.nodes[0].datadir, 'include2.conf')
7171
with open(os.path.join(self.nodes[0].datadir, 'bitcoin.conf'), 'a', encoding='utf-8') as conf:
72-
conf.write('includeconf={}\n'.format(inc_conf_file2_path))
72+
conf.write(f'includeconf={inc_conf_file2_path}\n')
7373

7474
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
7575
conf.write('testnot.datadir=1\n')
7676
with open(inc_conf_file2_path, 'w', encoding='utf-8') as conf:
7777
conf.write('[testnet]\n')
7878
self.restart_node(0)
79-
self.nodes[0].stop_node(expected_stderr='Warning: ' + inc_conf_file_path + ':1 Section [testnot] is not recognized.' + os.linesep + inc_conf_file2_path + ':1 Section [testnet] is not recognized.')
79+
self.nodes[0].stop_node(expected_stderr=f'Warning: {inc_conf_file_path}:1 Section [testnot] is not recognized.{os.linesep}{inc_conf_file2_path}:1 Section [testnet] is not recognized.')
8080

8181
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
8282
conf.write('') # clear
@@ -105,8 +105,8 @@ def test_args_log(self):
105105
'Command-line arg: rpcpassword=****',
106106
'Command-line arg: rpcuser=****',
107107
'Command-line arg: torpassword=****',
108-
'Config file arg: %s="1"' % self.chain,
109-
'Config file arg: [%s] server="1"' % self.chain,
108+
f'Config file arg: {self.chain}="1"',
109+
f'Config file arg: [{self.chain}] server="1"',
110110
],
111111
unexpected_msgs=[
112112
'alice:f7efda5c189b999524f151318c0c86$d5b51b3beffbc0',
@@ -235,29 +235,29 @@ def run_test(self):
235235

236236
# Check that using -datadir argument on non-existent directory fails
237237
self.nodes[0].datadir = new_data_dir
238-
self.nodes[0].assert_start_raises_init_error(['-datadir=' + new_data_dir], 'Error: Specified data directory "' + new_data_dir + '" does not exist.')
238+
self.nodes[0].assert_start_raises_init_error([f'-datadir={new_data_dir}'], f'Error: Specified data directory "{new_data_dir}" does not exist.')
239239

240240
# Check that using non-existent datadir in conf file fails
241241
conf_file = os.path.join(default_data_dir, "bitcoin.conf")
242242

243243
# datadir needs to be set before [chain] section
244244
conf_file_contents = open(conf_file, encoding='utf8').read()
245245
with open(conf_file, 'w', encoding='utf8') as f:
246-
f.write("datadir=" + new_data_dir + "\n")
246+
f.write(f"datadir={new_data_dir}\n")
247247
f.write(conf_file_contents)
248248

249-
self.nodes[0].assert_start_raises_init_error(['-conf=' + conf_file], 'Error: Error reading configuration file: specified data directory "' + new_data_dir + '" does not exist.')
249+
self.nodes[0].assert_start_raises_init_error([f'-conf={conf_file}'], f'Error: Error reading configuration file: specified data directory "{new_data_dir}" does not exist.')
250250

251251
# Create the directory and ensure the config file now works
252252
os.mkdir(new_data_dir)
253-
self.start_node(0, ['-conf='+conf_file])
253+
self.start_node(0, [f'-conf={conf_file}'])
254254
self.stop_node(0)
255255
assert os.path.exists(os.path.join(new_data_dir, self.chain, 'blocks'))
256256

257257
# Ensure command line argument overrides datadir in conf
258258
os.mkdir(new_data_dir_2)
259259
self.nodes[0].datadir = new_data_dir_2
260-
self.start_node(0, ['-datadir='+new_data_dir_2, '-conf='+conf_file])
260+
self.start_node(0, [f'-datadir={new_data_dir_2}', f'-conf={conf_file}'])
261261
assert os.path.exists(os.path.join(new_data_dir_2, self.chain, 'blocks'))
262262

263263

0 commit comments

Comments
 (0)