summaryrefslogtreecommitdiff
path: root/cmd2/transcript.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2021-04-06 16:48:08 -0400
committeranselor <anselor@gmail.com>2021-04-13 11:08:43 -0400
commit83a5ec0a0bdfc81efcc162478909862420d234a1 (patch)
tree5a753f8cb45695c71fab79df85f49a37d4ab2440 /cmd2/transcript.py
parente8b6456fc73a6f7bdb176251a1539a1886659f32 (diff)
downloadcmd2-git-83a5ec0a0bdfc81efcc162478909862420d234a1.tar.gz
Updated main code to use f-strings
Diffstat (limited to 'cmd2/transcript.py')
-rw-r--r--cmd2/transcript.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/cmd2/transcript.py b/cmd2/transcript.py
index 7ea5b8a9..83ede932 100644
--- a/cmd2/transcript.py
+++ b/cmd2/transcript.py
@@ -100,9 +100,7 @@ class Cmd2TestCase(unittest.TestCase):
try:
line = next(transcript)
except StopIteration as exc:
- msg = 'Transcript broke off while reading command beginning at line {} with\n{}'.format(
- line_num, command_parts[0]
- )
+ msg = f'Transcript broke off while reading command beginning at line {line_num} with\n{command_parts[0]}'
raise StopIteration(msg) from exc
line_num += 1
command = ''.join(command_parts)
@@ -112,9 +110,7 @@ class Cmd2TestCase(unittest.TestCase):
stop_msg = 'Command indicated application should quit, but more commands in transcript'
# Read the expected result from transcript
if ansi.strip_style(line).startswith(self.cmdapp.visible_prompt):
- message = '\nFile {}, line {}\nCommand was:\n{}\nExpected: (nothing)\nGot:\n{}\n'.format(
- fname, line_num, command, result
- )
+ message = f'\nFile {fname}, line {line_num}\nCommand was:\n{command}\nExpected: (nothing)\nGot:\n{result}\n'
self.assertTrue(not (result.strip()), message)
# If the command signaled the application to quit there should be no more commands
self.assertFalse(stop, stop_msg)
@@ -136,9 +132,7 @@ class Cmd2TestCase(unittest.TestCase):
# transform the expected text into a valid regular expression
expected = ''.join(expected_parts)
expected = self._transform_transcript_expected(expected)
- message = '\nFile {}, line {}\nCommand was:\n{}\nExpected:\n{}\nGot:\n{}\n'.format(
- fname, line_num, command, expected, result
- )
+ message = f'\nFile {fname}, line {line_num}\nCommand was:\n{command}\nExpected:\n{expected}\nGot:\n{result}\n'
self.assertTrue(re.match(expected, result, re.MULTILINE | re.DOTALL), message)
def _transform_transcript_expected(self, s: str) -> str: