jenkins-bot submitted this change.

View Change


Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[test] simplify page_tests.TestPageRepr

Change-Id: I4ca5975ff94d46a3cb0f0feb17140151f2570879
---
M tests/page_tests.py
1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/tests/page_tests.py b/tests/page_tests.py
index e61f7c7..b76de07 100755
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -658,34 +658,26 @@
def setUpClass(cls):
"""Initialize page instance."""
super().setUpClass()
+ cls._old_encoding = config.console_encoding
+ config.console_encoding = 'utf8'
cls.page = pywikibot.Page(cls.site, 'Ō')

- def setUp(self):
- """Force the console encoding to UTF-8."""
- super().setUp()
- self._old_encoding = config.console_encoding
- config.console_encoding = 'utf8'
-
- def tearDown(self):
+ @classmethod
+ def tearDownClass(cls):
"""Restore the original console encoding."""
- config.console_encoding = self._old_encoding
- super().tearDown()
+ config.console_encoding = cls._old_encoding
+ super().tearDownClass()

- def test_mainpage_type(self):
- """Test the return type of repr(Page(<main page>)) is str."""
+ def test_type(self):
+ """Test the return type of repr(Page(<page>)) is str."""
mainpage = self.get_mainpage()
self.assertIsInstance(repr(mainpage), str)
+ self.assertIsInstance(repr(self.page), str)

- def test_unicode_type(self):
- """Test the return type of repr(Page('<non-ascii>')) is str."""
- page = pywikibot.Page(self.get_site(), 'Ō')
- self.assertIsInstance(repr(page), str)
-
- def test_unicode_value(self):
- """Test to capture actual Python result pre unicode_literals."""
+ def test_value(self):
+ """Test to capture actual Python result."""
self.assertEqual(repr(self.page), "Page('Ō')")
self.assertEqual(f'{self.page!r}', "Page('Ō')")
- self.assertEqual(f'{self.page!r}', "Page('Ō')")


class TestPageBotMayEdit(TestCase):

To view, visit change 993211. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4ca5975ff94d46a3cb0f0feb17140151f2570879
Gerrit-Change-Number: 993211
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged