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