Show More
@@ -14,6 +14,7 b'' | |||||
14 | import sys |
|
14 | import sys | |
15 | import nose.tools as nt |
|
15 | import nose.tools as nt | |
16 | from IPython.utils.process import process_handler |
|
16 | from IPython.utils.process import process_handler | |
|
17 | from IPython.utils.tempdir import NamedFileInTemporaryDirectory | |||
17 |
|
18 | |||
18 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
19 | # Tests |
|
20 | # Tests | |
@@ -29,24 +30,22 b" print(a, '.', b)" | |||||
29 |
|
30 | |||
30 | IPython.embed() |
|
31 | IPython.embed() | |
31 |
|
32 | |||
32 |
print |
|
33 | print('bye!') | |
33 | """ |
|
34 | """ | |
34 |
|
35 | |||
35 | def test_ipython_embed(): |
|
36 | def test_ipython_embed(): | |
36 |
"""test that ` |
|
37 | """test that `IPython.embed()` works""" | |
37 | #with TempFile as f: |
|
38 | with NamedFileInTemporaryDirectory('file_with_embed.py') as f: | |
38 |
|
|
39 | f.write(_sample_embed) | |
39 |
|
40 | f.flush() | ||
40 | # run `python file_with_embed.py` |
|
41 | ||
41 | fname = '/home/pi/code/workspace/rambles/test_embed.py' |
|
42 | # run `python file_with_embed.py` | |
42 | cmd = [sys.executable, fname] |
|
43 | cmd = [sys.executable, f.name] | |
43 |
|
44 | |||
44 | #p = Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) |
|
45 | _, out, p = process_handler(cmd, | |
45 | print "\nhere's the command:", cmd |
|
46 | lambda p: (p.stdin.write("exit\r"), p.communicate()[:], p)) | |
46 | _, out, p = process_handler(cmd, |
|
47 | nt.assert_equal(p.returncode, 0) | |
47 | lambda p: (p.stdin.write("exit\r"), p.communicate()[:], p)) |
|
48 | nt.assert_in('3 . 14', out[0]) | |
48 | print out[1] |
|
49 | nt.assert_in('IPython', out[0]) | |
49 | nt.assert_equal(p.returncode, 0) |
|
50 | nt.assert_in('bye!', out[0]) | |
50 | nt.assert_equal(p.returncode, 0) |
|
|||
51 | #out, err, rc = tt.get_output_error_code(cmd) |
|
|||
52 |
|
51 |
General Comments 0
You need to be logged in to leave comments.
Login now