mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-33855: Still more edits and minimal tests for IDLE (GH-7784)
Part 3 of 3, continuing PR #7689. This covers 14 idlelib modules and their tests, rpc to zoomheight except for run (already done) and tooltip (being done separately).
This commit is contained in:
parent
00f9edb98d
commit
4d92158f4c
36 changed files with 358 additions and 97 deletions
30
Lib/idlelib/idle_test/test_rpc.py
Normal file
30
Lib/idlelib/idle_test/test_rpc.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
"Test rpc, coverage 20%."
|
||||
|
||||
from idlelib import rpc
|
||||
import unittest
|
||||
|
||||
import marshal
|
||||
|
||||
|
||||
class CodePicklerTest(unittest.TestCase):
|
||||
|
||||
def test_pickle_unpickle(self):
|
||||
def f(): return a + b + c
|
||||
func, (cbytes,) = rpc.pickle_code(f.__code__)
|
||||
self.assertIs(func, rpc.unpickle_code)
|
||||
self.assertIn(b'test_rpc.py', cbytes)
|
||||
code = rpc.unpickle_code(cbytes)
|
||||
self.assertEqual(code.co_names, ('a', 'b', 'c'))
|
||||
|
||||
def test_code_pickler(self):
|
||||
self.assertIn(type((lambda:None).__code__),
|
||||
rpc.CodePickler.dispatch_table)
|
||||
|
||||
def test_dumps(self):
|
||||
def f(): pass
|
||||
# The main test here is that pickling code does not raise.
|
||||
self.assertIn(b'test_rpc.py', rpc.dumps(f.__code__))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
Loading…
Add table
Add a link
Reference in a new issue