From cf94507e5568ad2554b5f68700160d7737db61cf Mon Sep 17 00:00:00 2001 From: Mats Wichmann Date: Sun, 29 Dec 2024 12:43:37 -0700 Subject: [PATCH] Rework a TestCommon test to look less ugly [skip appveyor[ 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 --- testing/framework/TestCommonTests.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/testing/framework/TestCommonTests.py b/testing/framework/TestCommonTests.py index 09e6bf656..3beca8010 100644 --- a/testing/framework/TestCommonTests.py +++ b/testing/framework/TestCommonTests.py @@ -181,24 +181,24 @@ class banner_TestCase(TestCommonTestCase): """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): -- 2.11.4.GIT