MCPcopy Create free account
hub / github.com/ipython/ipython / test_ipython_embed

Function test_ipython_embed

IPython/terminal/tests/test_embed.py:41–63  ·  view source on GitHub ↗

test that `IPython.embed()` works

()

Source from the content-addressed store, hash-verified

39_exit = b"exit\r"
40
41def test_ipython_embed():
42 """test that `IPython.embed()` works"""
43 with NamedFileInTemporaryDirectory('file_with_embed.py') as f:
44 f.write(_sample_embed)
45 f.flush()
46 f.close() # otherwise msft won't be able to read the file
47
48 # run `python file_with_embed.py`
49 cmd = [sys.executable, f.name]
50 env = os.environ.copy()
51 env['IPY_TEST_SIMPLE_PROMPT'] = '1'
52
53 p = subprocess.Popen(cmd, env=env, stdin=subprocess.PIPE,
54 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
55 out, err = p.communicate(_exit)
56 std = out.decode('UTF-8')
57
58 nt.assert_equal(p.returncode, 0)
59 nt.assert_in('3 . 14', std)
60 if os.name != 'nt':
61 # TODO: Fix up our different stdout references, see issue gh-14
62 nt.assert_in('IPython', std)
63 nt.assert_in('bye!', std)
64
65@skip_win32
66def test_nest_embed():

Callers

nothing calls this directly

Calls 5

writeMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected