Skip to content

Commit

Permalink
Merge "[test] simplify page_tests.TestPageRepr"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Jan 27, 2024
2 parents 2009f6e + 5d91d0f commit 199e96d
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions tests/page_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,34 +658,26 @@ class TestPageRepr(DefaultDrySiteTestCase):
def setUpClass(cls):
"""Initialize page instance."""
super().setUpClass()
cls.page = pywikibot.Page(cls.site, 'Ō')

def setUp(self):
"""Force the console encoding to UTF-8."""
super().setUp()
self._old_encoding = config.console_encoding
cls._old_encoding = config.console_encoding
config.console_encoding = 'utf8'
cls.page = pywikibot.Page(cls.site, 'Ō')

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):
Expand Down

0 comments on commit 199e96d

Please sign in to comment.