Skip to content

Commit 97c738f

Browse files
committed
[tests] Recommend f-strings for formatting, update feature_block to use them
1 parent 8ae9d31 commit 97c738f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

test/functional/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ don't have test cases for.
3434
- When subclassing the BitcoinTestFramework, place overrides for the
3535
`set_test_params()`, `add_options()` and `setup_xxxx()` methods at the top of
3636
the subclass, then locally-defined helper methods, then the `run_test()` method.
37-
- Use `'{}'.format(x)` for string formatting, not `'%s' % x`.
37+
- Use `f'{x}'` for string formatting in preference to `'{}'.format(x)` or `'%s' % x`.
3838

3939
#### Naming guidelines
4040

test/functional/feature_block.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def run_test(self):
119119
# Allow the block to mature
120120
blocks = []
121121
for i in range(NUM_BUFFER_BLOCKS_TO_GENERATE):
122-
blocks.append(self.next_block("maturitybuffer.{}".format(i)))
122+
blocks.append(self.next_block(f"maturitybuffer.{i}"))
123123
self.save_spendable_output()
124124
self.send_blocks(blocks)
125125

@@ -151,8 +151,8 @@ def run_test(self):
151151
if template.valid_in_block:
152152
continue
153153

154-
self.log.info("Reject block with invalid tx: %s", TxTemplate.__name__)
155-
blockname = "for_invalid.%s" % TxTemplate.__name__
154+
self.log.info(f"Reject block with invalid tx: {TxTemplate.__name__}")
155+
blockname = f"for_invalid.{TxTemplate.__name__}"
156156
badblock = self.next_block(blockname)
157157
badtx = template.get_tx()
158158
if TxTemplate != invalid_txs.InputMissing:
@@ -1355,12 +1355,12 @@ def next_block(self, number, spend=None, additional_coinbase_value=0, script=CSc
13551355

13561356
# save the current tip so it can be spent by a later block
13571357
def save_spendable_output(self):
1358-
self.log.debug("saving spendable output %s" % self.tip.vtx[0])
1358+
self.log.debug(f"saving spendable output {self.tip.vtx[0]}")
13591359
self.spendable_outputs.append(self.tip)
13601360

13611361
# get an output that we previously marked as spendable
13621362
def get_spendable_output(self):
1363-
self.log.debug("getting spendable output %s" % self.spendable_outputs[0].vtx[0])
1363+
self.log.debug(f"getting spendable output {self.spendable_outputs[0].vtx[0]}")
13641364
return self.spendable_outputs.pop(0).vtx[0]
13651365

13661366
# move the tip back to a previous block

0 commit comments

Comments
 (0)