##// END OF EJS Templates
Backport PR #4125: Basic exercise of `ipython [subcommand] -h` and help-all...
MinRK -
Show More
@@ -0,0 +1,25 b''
1 """Test NotebookApp"""
2
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2013 The IPython Development Team
5 #
6 # Distributed under the terms of the BSD License. The full license is in
7 # the file COPYING, distributed as part of this software.
8 #-----------------------------------------------------------------------------
9
10 #-----------------------------------------------------------------------------
11 # Imports
12 #-----------------------------------------------------------------------------
13
14 import nose.tools as nt
15
16 import IPython.testing.tools as tt
17
18 #-----------------------------------------------------------------------------
19 # Test functions
20 #-----------------------------------------------------------------------------
21
22 def test_help_output():
23 """ipython notebook --help-all works"""
24 tt.help_all_output_test('notebook')
25
@@ -0,0 +1,25 b''
1 """Test QtConsoleApp"""
2
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2013 The IPython Development Team
5 #
6 # Distributed under the terms of the BSD License. The full license is in
7 # the file COPYING, distributed as part of this software.
8 #-----------------------------------------------------------------------------
9
10 #-----------------------------------------------------------------------------
11 # Imports
12 #-----------------------------------------------------------------------------
13
14 import nose.tools as nt
15
16 import IPython.testing.tools as tt
17
18 #-----------------------------------------------------------------------------
19 # Test functions
20 #-----------------------------------------------------------------------------
21
22 def test_help_output():
23 """ipython qtconsole --help-all works"""
24 tt.help_all_output_test('qtconsole')
25
@@ -0,0 +1,37 b''
1 """Test help output of various IPython entry points"""
2
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2013 The IPython Development Team
5 #
6 # Distributed under the terms of the BSD License. The full license is in
7 # the file COPYING, distributed as part of this software.
8 #-----------------------------------------------------------------------------
9
10 #-----------------------------------------------------------------------------
11 # Imports
12 #-----------------------------------------------------------------------------
13
14 import IPython.testing.tools as tt
15
16 #-----------------------------------------------------------------------------
17 # Tests
18 #-----------------------------------------------------------------------------
19
20
21 def test_ipython_help():
22 tt.help_all_output_test()
23
24 def test_profile_help():
25 tt.help_all_output_test("profile")
26
27 def test_profile_list_help():
28 tt.help_all_output_test("profile list")
29
30 def test_profile_create_help():
31 tt.help_all_output_test("profile create")
32
33 def test_locate_help():
34 tt.help_all_output_test("locate")
35
36 def test_locate_profile_help():
37 tt.help_all_output_test("locate profile")
@@ -34,14 +34,13 b' import zmq'
34 from IPython.external.ssh import tunnel
34 from IPython.external.ssh import tunnel
35
35
36 # IPython imports
36 # IPython imports
37 # from IPython.config import Configurable
37 from IPython.config import Configurable
38 from IPython.core.profiledir import ProfileDir
38 from IPython.core.profiledir import ProfileDir
39 from IPython.utils.localinterfaces import LOCALHOST
39 from IPython.utils.localinterfaces import LOCALHOST
40 from IPython.utils.path import filefind, get_ipython_dir
40 from IPython.utils.path import filefind, get_ipython_dir
41 from IPython.utils.py3compat import str_to_bytes, bytes_to_str
41 from IPython.utils.py3compat import str_to_bytes, bytes_to_str
42 from IPython.utils.traitlets import (
42 from IPython.utils.traitlets import (
43 Bool, Integer, Unicode, CaselessStrEnum,
43 Bool, Integer, Unicode, CaselessStrEnum,
44 HasTraits,
45 )
44 )
46
45
47
46
@@ -383,7 +382,7 b' channel_socket_types = {'
383
382
384 port_names = [ "%s_port" % channel for channel in ('shell', 'stdin', 'iopub', 'hb', 'control')]
383 port_names = [ "%s_port" % channel for channel in ('shell', 'stdin', 'iopub', 'hb', 'control')]
385
384
386 class ConnectionFileMixin(HasTraits):
385 class ConnectionFileMixin(Configurable):
387 """Mixin for configurable classes that work with connection files"""
386 """Mixin for configurable classes that work with connection files"""
388
387
389 # The addresses for the communication channels
388 # The addresses for the communication channels
@@ -23,7 +23,7 b' import nose.tools as nt'
23
23
24 from IPython.kernel import KernelManager
24 from IPython.kernel import KernelManager
25 from IPython.kernel.tests.test_message_spec import execute, flush_channels
25 from IPython.kernel.tests.test_message_spec import execute, flush_channels
26 from IPython.testing import decorators as dec
26 from IPython.testing import decorators as dec, tools as tt
27 from IPython.utils import path, py3compat
27 from IPython.utils import path, py3compat
28
28
29 #-------------------------------------------------------------------------------
29 #-------------------------------------------------------------------------------
@@ -206,7 +206,6 b' def test_subprocess_error():'
206 _check_mp_mode(kc, expected=False)
206 _check_mp_mode(kc, expected=False)
207 _check_mp_mode(kc, expected=False, stream="stderr")
207 _check_mp_mode(kc, expected=False, stream="stderr")
208
208
209
210 # raw_input tests
209 # raw_input tests
211
210
212 def test_raw_input():
211 def test_raw_input():
@@ -249,3 +248,8 b' def test_eval_input():'
249 nt.assert_equal(reply['content']['status'], 'ok')
248 nt.assert_equal(reply['content']['status'], 'ok')
250 stdout, stderr = assemble_output(iopub)
249 stdout, stderr = assemble_output(iopub)
251 nt.assert_equal(stdout, "2\n")
250 nt.assert_equal(stdout, "2\n")
251
252
253 def test_help_output():
254 """ipython kernel --help-all works"""
255 tt.help_all_output_test('kernel')
@@ -25,6 +25,7 b' import glob'
25
25
26 # From IPython
26 # From IPython
27 from IPython.core.application import BaseIPythonApplication, base_aliases, base_flags
27 from IPython.core.application import BaseIPythonApplication, base_aliases, base_flags
28 from IPython.core.profiledir import ProfileDir
28 from IPython.config import catch_config_error, Configurable
29 from IPython.config import catch_config_error, Configurable
29 from IPython.utils.traitlets import (
30 from IPython.utils.traitlets import (
30 Unicode, List, Instance, DottedObjectName, Type, CaselessStrEnum,
31 Unicode, List, Instance, DottedObjectName, Type, CaselessStrEnum,
@@ -85,12 +86,13 b' class NbConvertApp(BaseIPythonApplication):'
85 return logging.INFO
86 return logging.INFO
86
87
87 def _classes_default(self):
88 def _classes_default(self):
88 classes = [NbConvertBase]
89 classes = [NbConvertBase, ProfileDir]
89 for pkg in (exporters, transformers, writers):
90 for pkg in (exporters, transformers, writers):
90 for name in dir(pkg):
91 for name in dir(pkg):
91 cls = getattr(pkg, name)
92 cls = getattr(pkg, name)
92 if isinstance(cls, type) and issubclass(cls, Configurable):
93 if isinstance(cls, type) and issubclass(cls, Configurable):
93 classes.append(cls)
94 classes.append(cls)
95
94 return classes
96 return classes
95
97
96 description = Unicode(
98 description = Unicode(
@@ -1,12 +1,10 b''
1 """
1 """Test NbConvertApp"""
2 Contains tests for the nbconvertapp
2
3 """
4 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
4 # Copyright (C) 2013 The IPython Development Team
6 #
7 #Distributed under the terms of the Modified BSD License.
8 #
5 #
9 #The full license is in the file COPYING.txt, distributed with this software.
6 # Distributed under the terms of the BSD License. The full license is in
7 # the file COPYING, distributed as part of this software.
10 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
11
9
12 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
@@ -18,9 +16,10 b' import glob'
18
16
19 from .base import TestsBase
17 from .base import TestsBase
20
18
19 import IPython.testing.tools as tt
21 from IPython.testing import decorators as dec
20 from IPython.testing import decorators as dec
22
21
23
22
24 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
25 # Constants
24 # Constants
26 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
@@ -35,13 +34,14 b' class TestNbConvertApp(TestsBase):'
35
34
36
35
37 def test_notebook_help(self):
36 def test_notebook_help(self):
38 """
37 """Will help show if no notebooks are specified?"""
39 Will help show if no notebooks are specified?
40 """
41 with self.create_temp_cwd():
38 with self.create_temp_cwd():
42 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
39 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
43 assert "see '--help-all'" in out
40 self.assertTrue("see '--help-all'" in out, out)
44
41
42 def test_help_output(self):
43 """ipython nbconvert --help-all works"""
44 tt.help_all_output_test('nbconvert')
45
45
46 def test_glob(self):
46 def test_glob(self):
47 """
47 """
@@ -18,11 +18,12 b' import time'
18 import nose.tools as nt
18 import nose.tools as nt
19 from nose import SkipTest
19 from nose import SkipTest
20
20
21 import IPython.testing.tools as tt
21 from IPython.testing import decorators as dec
22 from IPython.testing import decorators as dec
22 from IPython.utils import py3compat
23 from IPython.utils import py3compat
23
24
24 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
25 # Test functions begin
26 # Tests
26 #-----------------------------------------------------------------------------
27 #-----------------------------------------------------------------------------
27
28
28 @dec.skip_win32
29 @dec.skip_win32
@@ -55,3 +56,8 b' def test_console_starts():'
55 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
56 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
56 if p.isalive():
57 if p.isalive():
57 p.terminate()
58 p.terminate()
59
60 def test_help_output():
61 """ipython console --help-all works"""
62 tt.help_all_output_test('console')
63
@@ -8,7 +8,7 b' Authors'
8 from __future__ import absolute_import
8 from __future__ import absolute_import
9
9
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11 # Copyright (C) 2009-2011 The IPython Development Team
11 # Copyright (C) 2009 The IPython Development Team
12 #
12 #
13 # Distributed under the terms of the BSD License. The full license is in
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
14 # the file COPYING, distributed as part of this software.
@@ -18,6 +18,7 b' from __future__ import absolute_import'
18 # Imports
18 # Imports
19 #-----------------------------------------------------------------------------
19 #-----------------------------------------------------------------------------
20
20
21 import inspect
21 import os
22 import os
22 import re
23 import re
23 import sys
24 import sys
@@ -37,6 +38,7 b' except ImportError:'
37 has_nose = False
38 has_nose = False
38
39
39 from IPython.config.loader import Config
40 from IPython.config.loader import Config
41 from IPython.utils.process import get_output_error_code
40 from IPython.utils.text import list_strings
42 from IPython.utils.text import list_strings
41 from IPython.utils.io import temp_pyfile, Tee
43 from IPython.utils.io import temp_pyfile, Tee
42 from IPython.utils import py3compat
44 from IPython.utils import py3compat
@@ -412,3 +414,26 b' def monkeypatch(obj, name, attr):'
412 setattr(obj, name, attr)
414 setattr(obj, name, attr)
413 yield
415 yield
414 setattr(obj, name, orig)
416 setattr(obj, name, orig)
417
418
419 def help_output_test(subcommand=''):
420 """test that `ipython [subcommand] -h` works"""
421 cmd = ' '.join(get_ipython_cmd() + [subcommand, '-h'])
422 out, err, rc = get_output_error_code(cmd)
423 nt.assert_equal(rc, 0, err)
424 nt.assert_not_in("Traceback", err)
425 nt.assert_in("Options", out)
426 nt.assert_in("--help-all", out)
427 return out, err
428
429
430 def help_all_output_test(subcommand=''):
431 """test that `ipython [subcommand] --help-all` works"""
432 cmd = ' '.join(get_ipython_cmd() + [subcommand, '--help-all'])
433 out, err, rc = get_output_error_code(cmd)
434 nt.assert_equal(rc, 0, err)
435 nt.assert_not_in("Traceback", err)
436 nt.assert_in("Options", out)
437 nt.assert_in("Class parameters", out)
438 return out, err
439
General Comments 0
You need to be logged in to leave comments. Login now