Skip to content

Commit

Permalink
Rework a TestCommon test to look less ugly [skip appveyor[
Browse files Browse the repository at this point in the history
Insted of really long strings of repeated characters, use f-strings to
compose the "expected" output for the banner function tests.  This keeps
the code formatter from breaking things an ugly way, and is really more
"accurate" anyway.

Signed-off-by: Mats Wichmann <[email protected]>
  • Loading branch information
mwichmann committed Dec 29, 2024
1 parent c9d9fa5 commit cf94507
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions testing/framework/TestCommonTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,24 @@ def test_banner(self) -> None:
"""Test banner()"""
tc = TestCommon.TestCommon(workdir='')

b = tc.banner('xyzzy ')
assert (
b
== "xyzzy =========================================================================="
), b
text = 'xyzzy '
b = tc.banner(text)
expect = f"{text}{tc.banner_char * (tc.banner_width - len(text))}"
assert b == expect, b

tc.banner_width = 10
b = tc.banner(text)
expect = f"{text}{tc.banner_char * (tc.banner_width - len(text))}"
assert b == expect, b

b = tc.banner('xyzzy ')
assert b == "xyzzy ====", b

b = tc.banner('xyzzy ', 20)
assert b == "xyzzy ==============", b
b = tc.banner(text, 20)
expect = f"{text}{tc.banner_char * (20 - len(text))}"
assert b == expect, b

tc.banner_char = '-'

b = tc.banner('xyzzy ')
assert b == "xyzzy ----", b
b = tc.banner(text)
expect = f"{text}{tc.banner_char * (tc.banner_width - len(text))}"
assert b == expect, b


class must_be_writable_TestCase(TestCommonTestCase):
Expand Down

0 comments on commit cf94507

Please sign in to comment.