Page MenuHomePhabricator

test: use f-strings in rpc_* tests
ClosedPublic

Authored by PiRK on Feb 28 2023, 16:11.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa643655a8bc2: test: use f-strings in rpc_* tests
Summary

scripted diff

flynt --transform-concats test/functional/rpc_*

Manual edits:

  • remove unnecessary string formatting (f"{-1}" -> "-1")
  • convert more "...".format(..) instances to f-strings. These were missed by flynt presumably because it sometimes cannot understand multiline strings formatted by autopep8

Depends on D13196

Test Plan

test/functional/test_runner.py rpc_*

Event Timeline

PiRK requested review of this revision.Feb 28 2023, 16:11
Fabien requested changes to this revision.Feb 28 2023, 16:40
Fabien added a subscriber: Fabien.
Fabien added inline comments.
test/functional/rpc_getblockstats.py
163
This revision now requires changes to proceed.Feb 28 2023, 16:40
PiRK edited the summary of this revision. (Show Details)

address feedback and convert some more strings (missed by flynt because of strange multiline style)

TIL conversion fields (https://docs.python.org/3/library/string.html#format-string-syntax)

>>> class A:
...      def __str__(self):
...          return "foo"
...      def __repr__(self):
...          return "bår"
...
>>> a = A()
>>>
>>> f"{a}"
'foo'
>>> f"{a!s}"
'foo'
>>> f"{a!r}"
'bår'
>>> f"{a!a}"
'b\\xe5r'
>>>
This revision is now accepted and ready to land.Mar 1 2023, 08:59
This revision was automatically updated to reflect the committed changes.