GeezerVison is showing github.com — bpo-33855: Still more edits and minimal tests for IDLE (GH-7784) · miss-islington/cpython@736cb6f
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/autoexpand.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -92,5 +92,5 @@ def getprevword(self): | 92 | 92 |
| 93 | 93 |
| 94 | 94 | if __name__ == '__main__': | 95 | | - import unittest | 96 | | - unittest.main('idlelib.idle_test.test_autoexpand', verbosity=2) | | 95 | + from unittest import main | | 96 | + main('idlelib.idle_test.test_autoexpand', verbosity=2) |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/codecontext.py +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -233,6 +233,8 @@ def config_timer_event(self): | 233 | 233 | CodeContext.reload() | 234 | 234 |
| 235 | 235 |
| 236 | | -if __name__ == "__main__": # pragma: no cover | 237 | | - import unittest | 238 | | - unittest.main('idlelib.idle_test.test_codecontext', verbosity=2, exit=False) | | 236 | +if __name__ == "__main__": | | 237 | + from unittest import main | | 238 | + main('idlelib.idle_test.test_codecontext', verbosity=2, exit=False) | | 239 | + | | 240 | + # Add htest. |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/config.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -925,7 +925,7 @@ def dumpCfg(cfg): | 925 | 925 | print('\nlines = ', line, ', crc = ', crc, sep='') | 926 | 926 |
| 927 | 927 | if __name__ == '__main__': | 928 | | - import unittest | 929 | | - unittest.main('idlelib.idle_test.test_config', | 930 | | - verbosity=2, exit=False) | 931 | | - #_dump() | | 928 | + from unittest import main | | 929 | + main('idlelib.idle_test.test_config', verbosity=2, exit=False) | | 930 | + | | 931 | + # Run revised _dump() as htest? |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/config_key.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -291,8 +291,8 @@ def bind_ok(self, keys): | 291 | 291 |
| 292 | 292 |
| 293 | 293 | if __name__ == '__main__': | 294 | | - import unittest | 295 | | - unittest.main('idlelib.idle_test.test_config_key', verbosity=2, exit=False) | | 294 | + from unittest import main | | 295 | + main('idlelib.idle_test.test_config_key', verbosity=2, exit=False) | 296 | 296 |
| 297 | 297 | from idlelib.idle_test.htest import run | 298 | 298 | run(GetKeysDialog) |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/configdialog.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2269,8 +2269,8 @@ def _configure_canvas(event): | 2269 | 2269 |
| 2270 | 2270 |
| 2271 | 2271 | if __name__ == '__main__': | 2272 | | - import unittest | 2273 | | - unittest.main('idlelib.idle_test.test_configdialog', | 2274 | | - verbosity=2, exit=False) | | 2272 | + from unittest import main | | 2273 | + main('idlelib.idle_test.test_configdialog', verbosity=2, exit=False) | | 2274 | + | 2275 | 2275 | from idlelib.idle_test.htest import run | 2276 | 2276 | run(ConfigDialog) |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/idle_test/test_codecontext.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 |
| 3 | 3 | from idlelib import codecontext | 4 | 4 | import unittest | 5 | | -from unittest import mock | 6 | 5 | from test.support import requires | 7 | 6 | from tkinter import Tk, Frame, Text, TclError | 8 | 7 |
| | 8 | +from unittest import mock | 9 | 9 | import re | 10 | 10 | from idlelib import config | 11 | 11 |
| |
Collapse file Copy file name to clipboard +30Lines changed: 30 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +"Test rpc, coverage 20%." | | 2 | + | | 3 | +from idlelib import rpc | | 4 | +import unittest | | 5 | + | | 6 | +import marshal | | 7 | + | | 8 | + | | 9 | +class CodePicklerTest(unittest.TestCase): | | 10 | + | | 11 | + def test_pickle_unpickle(self): | | 12 | + def f(): return a + b + c | | 13 | + func, (cbytes,) = rpc.pickle_code(f.__code__) | | 14 | + self.assertIs(func, rpc.unpickle_code) | | 15 | + self.assertIn(b'test_rpc.py', cbytes) | | 16 | + code = rpc.unpickle_code(cbytes) | | 17 | + self.assertEqual(code.co_names, ('a', 'b', 'c')) | | 18 | + | | 19 | + def test_code_pickler(self): | | 20 | + self.assertIn(type((lambda:None).__code__), | | 21 | + rpc.CodePickler.dispatch_table) | | 22 | + | | 23 | + def test_dumps(self): | | 24 | + def f(): pass | | 25 | + # The main test here is that pickling code does not raise. | | 26 | + self.assertIn(b'test_rpc.py', rpc.dumps(f.__code__)) | | 27 | + | | 28 | + | | 29 | +if __name__ == '__main__': | | 30 | + unittest.main(verbosity=2) |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/idle_test/test_rstrip.py +12-8Lines changed: 12 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +"Test rstrip, coverage 100%." | | 2 | + | | 3 | +from idlelib import rstrip | 1 | 4 | import unittest | 2 | | -import idlelib.rstrip as rs | 3 | 5 | from idlelib.idle_test.mock_idle import Editor | 4 | 6 |
| 5 | 7 | class rstripTest(unittest.TestCase): | 6 | 8 |
| 7 | 9 | def test_rstrip_line(self): | 8 | 10 | editor = Editor() | 9 | 11 | text = editor.text | 10 | | - do_rstrip = rs.RstripExtension(editor).do_rstrip | | 12 | + do_rstrip = rstrip.RstripExtension(editor).do_rstrip | 11 | 13 |
| 12 | 14 | do_rstrip() | 13 | 15 | self.assertEqual(text.get('1.0', 'insert'), '') | @@ -20,12 +22,12 @@ def test_rstrip_line(self): | 20 | 22 |
| 21 | 23 | def test_rstrip_multiple(self): | 22 | 24 | editor = Editor() | 23 | | - # Uncomment following to verify that test passes with real widgets. | 24 | | -## from idlelib.editor import EditorWindow as Editor | 25 | | -## from tkinter import Tk | 26 | | -## editor = Editor(root=Tk()) | | 25 | + # Comment above, uncomment 3 below to test with real Editor & Text. | | 26 | + #from idlelib.editor import EditorWindow as Editor | | 27 | + #from tkinter import Tk | | 28 | + #editor = Editor(root=Tk()) | 27 | 29 | text = editor.text | 28 | | - do_rstrip = rs.RstripExtension(editor).do_rstrip | | 30 | + do_rstrip = rstrip.RstripExtension(editor).do_rstrip | 29 | 31 |
| 30 | 32 | original = ( | 31 | 33 | "Line with an ending tab \n" | @@ -45,5 +47,7 @@ def test_rstrip_multiple(self): | 45 | 47 | do_rstrip() | 46 | 48 | self.assertEqual(text.get('1.0', 'insert'), stripped) | 47 | 49 |
| | 50 | + | | 51 | + | 48 | 52 | if __name__ == '__main__': | 49 | | - unittest.main(verbosity=2, exit=False) | | 53 | + unittest.main(verbosity=2) |
Collapse file Copy file name to clipboard +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +"Test runscript, coverage 16%." | | 2 | + | | 3 | +from idlelib import runscript | | 4 | +import unittest | | 5 | +from test.support import requires | | 6 | +from tkinter import Tk | | 7 | +from idlelib.editor import EditorWindow | | 8 | + | | 9 | + | | 10 | +class ScriptBindingTest(unittest.TestCase): | | 11 | + | | 12 | + @classmethod | | 13 | + def setUpClass(cls): | | 14 | + requires('gui') | | 15 | + cls.root = Tk() | | 16 | + cls.root.withdraw() | | 17 | + | | 18 | + @classmethod | | 19 | + def tearDownClass(cls): | | 20 | + cls.root.update_idletasks() | | 21 | + for id in cls.root.tk.call('after', 'info'): | | 22 | + cls.root.after_cancel(id) # Need for EditorWindow. | | 23 | + cls.root.destroy() | | 24 | + del cls.root | | 25 | + | | 26 | + def test_init(self): | | 27 | + ew = EditorWindow(root=self.root) | | 28 | + sb = runscript.ScriptBinding(ew) | | 29 | + ew._close() | | 30 | + | | 31 | + | | 32 | +if __name__ == '__main__': | | 33 | + unittest.main(verbosity=2) |
Collapse file Copy file name to clipboardExpand all lines: Lib/idlelib/idle_test/test_scrolledlist.py +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -''' Test idlelib.scrolledlist. | | 1 | +"Test scrolledlist, coverage 38%." | 2 | 2 |
| 3 | | -Coverage: 39% | 4 | | -''' | 5 | | -from idlelib import scrolledlist | | 3 | +from idlelib.scrolledlist import ScrolledList | | 4 | +import unittest | 6 | 5 | from test.support import requires | 7 | 6 | requires('gui') | 8 | | -import unittest | 9 | 7 | from tkinter import Tk | 10 | 8 |
| 11 | 9 |
| @@ -22,7 +20,7 @@ def tearDownClass(cls): | 22 | 20 |
| 23 | 21 |
| 24 | 22 | def test_init(self): | 25 | | - scrolledlist.ScrolledList(self.root) | | 23 | + ScrolledList(self.root) | 26 | 24 |
| 27 | 25 |
| 28 | 26 | if __name__ == '__main__': | |
|