Show More
@@ -1,34 +1,32 b'' | |||
|
1 | 1 | """Test installing editor hooks""" |
|
2 | 2 | import sys |
|
3 | 3 | from unittest import mock |
|
4 | 4 | |
|
5 | import nose.tools as nt | |
|
6 | ||
|
7 | 5 | from IPython import get_ipython |
|
8 | 6 | from IPython.lib import editorhooks |
|
9 | 7 | |
|
10 | 8 | def test_install_editor(): |
|
11 | 9 | called = [] |
|
12 | 10 | def fake_popen(*args, **kwargs): |
|
13 | 11 | called.append({ |
|
14 | 12 | 'args': args, |
|
15 | 13 | 'kwargs': kwargs, |
|
16 | 14 | }) |
|
17 | 15 | return mock.MagicMock(**{'wait.return_value': 0}) |
|
18 | 16 | editorhooks.install_editor('foo -l {line} -f {filename}', wait=False) |
|
19 | 17 | |
|
20 | 18 | with mock.patch('subprocess.Popen', fake_popen): |
|
21 | 19 | get_ipython().hooks.editor('the file', 64) |
|
22 | 20 | |
|
23 |
|
|
|
24 |
args = called[0][ |
|
|
25 |
kwargs = called[0][ |
|
|
26 | ||
|
27 |
|
|
|
28 | ||
|
29 |
if sys.platform.startswith( |
|
|
30 |
expected = [ |
|
|
21 | assert len(called) == 1 | |
|
22 | args = called[0]["args"] | |
|
23 | kwargs = called[0]["kwargs"] | |
|
24 | ||
|
25 | assert kwargs == {"shell": True} | |
|
26 | ||
|
27 | if sys.platform.startswith("win"): | |
|
28 | expected = ["foo", "-l", "64", "-f", "the file"] | |
|
31 | 29 | else: |
|
32 | 30 | expected = "foo -l 64 -f 'the file'" |
|
33 | 31 | cmd = args[0] |
|
34 |
|
|
|
32 | assert cmd == expected |
General Comments 0
You need to be logged in to leave comments.
Login now