()
| 8 | from IPython.lib import editorhooks |
| 9 | |
| 10 | def test_install_editor(): |
| 11 | called = [] |
| 12 | def fake_popen(*args, **kwargs): |
| 13 | called.append({ |
| 14 | 'args': args, |
| 15 | 'kwargs': kwargs, |
| 16 | }) |
| 17 | return mock.MagicMock(**{'wait.return_value': 0}) |
| 18 | editorhooks.install_editor('foo -l {line} -f {filename}', wait=False) |
| 19 | |
| 20 | with mock.patch('subprocess.Popen', fake_popen): |
| 21 | get_ipython().hooks.editor('the file', 64) |
| 22 | |
| 23 | nt.assert_equal(len(called), 1) |
| 24 | args = called[0]['args'] |
| 25 | kwargs = called[0]['kwargs'] |
| 26 | |
| 27 | nt.assert_equal(kwargs, {'shell': True}) |
| 28 | |
| 29 | if sys.platform.startswith('win'): |
| 30 | expected = ['foo', '-l', '64', '-f', 'the file'] |
| 31 | else: |
| 32 | expected = "foo -l 64 -f 'the file'" |
| 33 | cmd = args[0] |
| 34 | nt.assert_equal(cmd, expected) |
nothing calls this directly
no test coverage detected