jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1242465?usp=email )
Change subject: [UI] Add tests for background colors in ui_tests.py
......................................................................
[UI] Add tests for background colors in ui_tests.py
Added test_background_color to FakeUITest to increase code coverage
and address the long-standing TODO. This verifies foreground and
background color parsing in the terminal interface.
Bug: T137914
Change-Id: Ie70f592cbc90731c95b56d366e84b1e00824217b
---
M tests/ui_tests.py
1 file changed, 9 insertions(+), 2 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index fabe471..00e09a5 100755
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
"""Tests for the user interface."""
#
-# (C) Pywikibot team, 2008-2025
+# (C) Pywikibot team, 2008-2026
#
# Distributed under the terms of the MIT license.
#
@@ -412,7 +412,6 @@
self.assertEqual(self.t('ຫ'), 'h')
-# TODO: add tests for background colors.
class FakeUITest(TestCase):
"""Test case to allow doing uncolorized general UI tests."""
@@ -494,6 +493,14 @@
self.ui_obj.stdout)
self.assertEqual(f.getvalue(), self.expected + '\n')
+ def test_background_color(self) -> None:
+ """Test a string using both foreground and background colors."""
+ self._colors = (('red;yellow', 6), ('default', 10))
+ with redirect_stdout(self.redirect) as f:
+ self.ui_obj._print('Hello <<red;yellow>>world you!',
+ self.ui_obj.stdout)
+ self.assertEqual(f.getvalue(), self.expected)
+
class FakeUIColorizedTestBase(TestCase):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1242465?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ie70f592cbc90731c95b56d366e84b1e00824217b
Gerrit-Change-Number: 1242465
Gerrit-PatchSet: 3
Gerrit-Owner: Raushan 31 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]