bpo-41876: Overload __repr__ for tkinter Font objects (GH-22450)
This commit is contained in:
parent
0cafcd3c56
commit
b4d895336a
|
@ -100,6 +100,10 @@ class Font:
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<{self.__class__.__module__}.{self.__class__.__qualname__}" \
|
||||||
|
f" object {self.name!r}>"
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
if not isinstance(other, Font):
|
if not isinstance(other, Font):
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
|
|
|
@ -101,6 +101,12 @@ class FontTest(AbstractTkTest, unittest.TestCase):
|
||||||
self.assertTrue(name)
|
self.assertTrue(name)
|
||||||
self.assertIn(fontname, names)
|
self.assertIn(fontname, names)
|
||||||
|
|
||||||
|
def test_repr(self):
|
||||||
|
self.assertEqual(
|
||||||
|
repr(self.font), f'<tkinter.font.Font object {fontname!r}>'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
tests_gui = (FontTest, )
|
tests_gui = (FontTest, )
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -1353,6 +1353,7 @@ Zero Piraeus
|
||||||
Antoine Pitrou
|
Antoine Pitrou
|
||||||
Jean-François Piéronne
|
Jean-François Piéronne
|
||||||
Oleg Plakhotnyuk
|
Oleg Plakhotnyuk
|
||||||
|
Anatoliy Platonov
|
||||||
Marcel Plch
|
Marcel Plch
|
||||||
Remi Pointel
|
Remi Pointel
|
||||||
Jon Poler
|
Jon Poler
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Tkinter font class repr uses font name
|
Loading…
Reference in New Issue