test that `IPython.embed()` works
()
| 40 | |
| 41 | |
| 42 | def test_ipython_embed(): |
| 43 | """test that `IPython.embed()` works""" |
| 44 | with NamedFileInTemporaryDirectory("file_with_embed.py", "w") as f: |
| 45 | f.write(_sample_embed) |
| 46 | f.flush() |
| 47 | f.close() # otherwise msft won't be able to read the file |
| 48 | |
| 49 | # run `python file_with_embed.py` |
| 50 | cmd = [sys.executable, f.name] |
| 51 | env = os.environ.copy() |
| 52 | env["IPY_TEST_SIMPLE_PROMPT"] = "1" |
| 53 | |
| 54 | p = subprocess.Popen( |
| 55 | cmd, |
| 56 | env=env, |
| 57 | stdin=subprocess.PIPE, |
| 58 | stdout=subprocess.PIPE, |
| 59 | stderr=subprocess.PIPE, |
| 60 | text=True, |
| 61 | encoding="UTF-8", |
| 62 | ) |
| 63 | std, err = p.communicate(_exit) |
| 64 | assert isinstance(std, str), (std, err, p.returncode) |
| 65 | |
| 66 | assert p.returncode == 0, (p.returncode, std) |
| 67 | assert "3 . 14" in std |
| 68 | if os.name != "nt": |
| 69 | # TODO: Fix up our different stdout references, see issue gh-14 |
| 70 | assert "IPython" in std |
| 71 | assert "bye!" in std |
| 72 | |
| 73 | |
| 74 | @skip_win32 |
nothing calls this directly
no test coverage detected
searching dependent graphs…