##// END OF EJS Templates
3 at last, 3 at last, thank Guido BDFL......
Paul Ivanov -
Show More
@@ -33,19 +33,22 b' IPython.embed()'
33 print('bye!')
33 print('bye!')
34 """
34 """
35
35
36 _exit = "exit\r".encode('UTF-8')
37
36 def test_ipython_embed():
38 def test_ipython_embed():
37 """test that `IPython.embed()` works"""
39 """test that `IPython.embed()` works"""
38 with NamedFileInTemporaryDirectory('file_with_embed.py') as f:
40 with NamedFileInTemporaryDirectory('file_with_embed.py') as f:
39 f.write(_sample_embed)
41 f.write(_sample_embed.encode('UTF-8'))
40 f.flush()
42 f.flush()
41
43
42 # run `python file_with_embed.py`
44 # run `python file_with_embed.py`
43 cmd = [sys.executable, f.name]
45 cmd = [sys.executable, f.name]
44
46
45 _, out, p = process_handler(cmd,
47 _, out, p = process_handler(cmd,
46 lambda p: (p.stdin.write("exit\r"), p.communicate()[:], p))
48 lambda p: (p.stdin.write(_exit), p.communicate()[:], p))
49 std = out[0].decode('UTF-8')
47 nt.assert_equal(p.returncode, 0)
50 nt.assert_equal(p.returncode, 0)
48 nt.assert_in('3 . 14', out[0])
51 nt.assert_in('3 . 14', std)
49 nt.assert_in('IPython', out[0])
52 nt.assert_in('IPython', std)
50 nt.assert_in('bye!', out[0])
53 nt.assert_in('bye!', std)
51
54
General Comments 0
You need to be logged in to leave comments. Login now