summaryrefslogtreecommitdiffstats
path: root/Lib/tkinter/test/test_tkinter
diff options
context:
space:
mode:
authorDesmond Cheong <desmondcheongzx@gmail.com>2020-12-25 21:18:06 (GMT)
committerGitHub <noreply@github.com>2020-12-25 21:18:06 (GMT)
commit36a779e64c580519550aa6478c5aa8c58b8fa7b6 (patch)
tree9ee86f0cbe8e6a0de0cbe8f3544374ca0fdd7b8a /Lib/tkinter/test/test_tkinter
parent675c97eb6c7c14c6a68ebf476c52931c1e5c1220 (diff)
downloadcpython-36a779e64c580519550aa6478c5aa8c58b8fa7b6.zip
cpython-36a779e64c580519550aa6478c5aa8c58b8fa7b6.tar.gz
cpython-36a779e64c580519550aa6478c5aa8c58b8fa7b6.tar.bz2
bpo-35728: Add root parameter to tkinter.font.nametofont() (GH-23885)
Diffstat (limited to 'Lib/tkinter/test/test_tkinter')
-rw-r--r--Lib/tkinter/test/test_tkinter/test_font.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/tkinter/test/test_tkinter/test_font.py
index 3f71209..0354c5f 100644
--- a/Lib/tkinter/test/test_tkinter/test_font.py
+++ b/Lib/tkinter/test/test_tkinter/test_font.py
@@ -101,6 +101,11 @@ class FontTest(AbstractTkTest, unittest.TestCase):
self.assertTrue(name)
self.assertIn(fontname, names)
+ def test_nametofont(self):
+ testfont = font.nametofont(fontname, root=self.root)
+ self.assertIsInstance(testfont, font.Font)
+ self.assertEqual(testfont.name, fontname)
+
def test_repr(self):
self.assertEqual(
repr(self.font), f'<tkinter.font.Font object {fontname!r}>'
@@ -136,6 +141,16 @@ class DefaultRootTest(AbstractDefaultRootTest, unittest.TestCase):
tkinter.NoDefaultRoot()
self.assertRaises(RuntimeError, font.names)
+ def test_nametofont(self):
+ self.assertRaises(RuntimeError, font.nametofont, fontname)
+ root = tkinter.Tk()
+ testfont = font.nametofont(fontname)
+ self.assertIsInstance(testfont, font.Font)
+ self.assertEqual(testfont.name, fontname)
+ root.destroy()
+ tkinter.NoDefaultRoot()
+ self.assertRaises(RuntimeError, font.nametofont, fontname)
+
tests_gui = (FontTest, DefaultRootTest)