From 2518fa8326578c0407e45a1397b78cbccd4b55b0 Mon Sep 17 00:00:00 2001 From: Terry Jan Reedy Date: Sun, 12 Jun 2016 15:49:20 -0400 Subject: Issue #27239: Continue refactoring idlelib.macosx and adding macosx tests. --- Lib/idlelib/idle_test/test_macosx.py | 42 ++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 7 deletions(-) (limited to 'Lib/idlelib/idle_test/test_macosx.py') diff --git a/Lib/idlelib/idle_test/test_macosx.py b/Lib/idlelib/idle_test/test_macosx.py index 0f90fb65f14..d7f8f5db271 100644 --- a/Lib/idlelib/idle_test/test_macosx.py +++ b/Lib/idlelib/idle_test/test_macosx.py @@ -1,4 +1,6 @@ -'''Test idlelib.macosx.py +'''Test idlelib.macosx.py. + +Coverage: 71% on Windows. ''' from idlelib import macosx from test.support import requires @@ -6,8 +8,8 @@ import sys import tkinter as tk import unittest import unittest.mock as mock +from idlelib.filelist import FileList -MAC = sys.platform == 'darwin' mactypes = {'carbon', 'cocoa', 'xquartz'} nontypes = {'other'} alltypes = mactypes | nontypes @@ -20,21 +22,23 @@ class InitTktypeTest(unittest.TestCase): def setUpClass(cls): requires('gui') cls.root = tk.Tk() + cls.orig_platform = macosx.platform @classmethod def tearDownClass(cls): cls.root.update_idletasks() cls.root.destroy() del cls.root + macosx.platform = cls.orig_platform def test_init_sets_tktype(self): "Test that _init_tk_type sets _tk_type according to platform." - for root in (None, self.root): - with self.subTest(root=root): + for platform, types in ('darwin', alltypes), ('other', nontypes): + with self.subTest(platform=platform): + macosx.platform = platform macosx._tk_type == None - macosx._init_tk_type(root) - self.assertIn(macosx._tk_type, - mactypes if MAC else nontypes) + macosx._init_tk_type() + self.assertIn(macosx._tk_type, types) class IsTypeTkTest(unittest.TestCase): @@ -65,5 +69,29 @@ class IsTypeTkTest(unittest.TestCase): (func()) +class SetupTest(unittest.TestCase): + "Test setupApp." + + @classmethod + def setUpClass(cls): + requires('gui') + cls.root = tk.Tk() + + @classmethod + def tearDownClass(cls): + cls.root.update_idletasks() + cls.root.destroy() + del cls.root + + def test_setupapp(self): + "Call setupApp with each possible graphics type." + root = self.root + flist = FileList(root) + for tktype in alltypes: + with self.subTest(tktype=tktype): + macosx._tk_type = tktype + macosx.setupApp(root, flist) + + if __name__ == '__main__': unittest.main(verbosity=2) -- cgit v1.2.3