Coverage for idle_test/test_rpc.py: 80%

17 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-11 13:22 -0700

1"Test rpc, coverage 20%." 

2 

3from idlelib import rpc 

4import unittest 

5 

6 

7 

8class CodePicklerTest(unittest.TestCase): 

9 

10 def test_pickle_unpickle(self): 

11 def f(): return a + b + c 11 ↛ exitline 11 didn't return from function 'f', because the return on line 11 wasn't executed1b

12 func, (cbytes,) = rpc.pickle_code(f.__code__) 1b

13 self.assertIs(func, rpc.unpickle_code) 1b

14 self.assertIn(b'test_rpc.py', cbytes) 1b

15 code = rpc.unpickle_code(cbytes) 1b

16 self.assertEqual(code.co_names, ('a', 'b', 'c')) 1b

17 

18 def test_code_pickler(self): 

19 self.assertIn(type((lambda:None).__code__), 19 ↛ exitline 19 didn't run the lambda on line 191d

20 rpc.CodePickler.dispatch_table) 

21 

22 def test_dumps(self): 

23 def f(): pass 23 ↛ exitline 23 didn't return from function 'f'1c

24 # The main test here is that pickling code does not raise. 

25 self.assertIn(b'test_rpc.py', rpc.dumps(f.__code__)) 1c

26 

27 

28if __name__ == '__main__': 28 ↛ 29line 28 didn't jump to line 29, because the condition on line 28 was never true

29 unittest.main(verbosity=2)