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 |
|
|
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( |
|
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(): | |
@@ -250,3 +249,8 b' def test_eval_input():' | |||||
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") | |
252 |
|
251 | |||
|
252 | ||||
|
253 | def test_help_output(): | |||
|
254 | """ipython kernel --help-all works""" | |||
|
255 | tt.help_all_output_test('kernel') | |||
|
256 |
@@ -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, | |
@@ -62,8 +63,8 b' nbconvert_aliases.update({' | |||||
62 | 'writer' : 'NbConvertApp.writer_class', |
|
63 | 'writer' : 'NbConvertApp.writer_class', | |
63 | 'post': 'NbConvertApp.postprocessor_class', |
|
64 | 'post': 'NbConvertApp.postprocessor_class', | |
64 | 'output': 'NbConvertApp.output_base', |
|
65 | 'output': 'NbConvertApp.output_base', | |
65 |
'offline-slides': 'RevealHelp |
|
66 | 'offline-slides': 'RevealHelpPreprocessor.url_prefix', | |
66 |
'slide-notes': 'RevealHelp |
|
67 | 'slide-notes': 'RevealHelpPreprocessor.speaker_notes' | |
67 | }) |
|
68 | }) | |
68 |
|
69 | |||
69 | nbconvert_flags = {} |
|
70 | nbconvert_flags = {} | |
@@ -87,12 +88,13 b' class NbConvertApp(BaseIPythonApplication):' | |||||
87 | return logging.INFO |
|
88 | return logging.INFO | |
88 |
|
89 | |||
89 | def _classes_default(self): |
|
90 | def _classes_default(self): | |
90 | classes = [NbConvertBase] |
|
91 | classes = [NbConvertBase, ProfileDir] | |
91 | for pkg in (exporters, preprocessors, writers): |
|
92 | for pkg in (exporters, preprocessors, writers): | |
92 | for name in dir(pkg): |
|
93 | for name in dir(pkg): | |
93 | cls = getattr(pkg, name) |
|
94 | cls = getattr(pkg, name) | |
94 | if isinstance(cls, type) and issubclass(cls, Configurable): |
|
95 | if isinstance(cls, type) and issubclass(cls, Configurable): | |
95 | classes.append(cls) |
|
96 | classes.append(cls) | |
|
97 | ||||
96 | return classes |
|
98 | return classes | |
97 |
|
99 | |||
98 | description = Unicode( |
|
100 | description = Unicode( |
@@ -1,12 +1,10 b'' | |||||
1 | """ |
|
1 | """Test NbConvertApp""" | |
2 | Contains tests for the nbconvertapp |
|
2 | ||
3 | """ |
|
|||
4 | #----------------------------------------------------------------------------- |
|
3 | #----------------------------------------------------------------------------- | |
5 |
#Copyright ( |
|
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 |
|
40 | self.assertIn("see '--help-all'", 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 |
|
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 | |
@@ -408,3 +410,26 b' def monkeypatch(obj, name, attr):' | |||||
408 | setattr(obj, name, attr) |
|
410 | setattr(obj, name, attr) | |
409 | yield |
|
411 | yield | |
410 | setattr(obj, name, orig) |
|
412 | setattr(obj, name, orig) | |
|
413 | ||||
|
414 | ||||
|
415 | def help_output_test(subcommand=''): | |||
|
416 | """test that `ipython [subcommand] -h` works""" | |||
|
417 | cmd = ' '.join(get_ipython_cmd() + [subcommand, '-h']) | |||
|
418 | out, err, rc = get_output_error_code(cmd) | |||
|
419 | nt.assert_equal(rc, 0, err) | |||
|
420 | nt.assert_not_in("Traceback", err) | |||
|
421 | nt.assert_in("Options", out) | |||
|
422 | nt.assert_in("--help-all", out) | |||
|
423 | return out, err | |||
|
424 | ||||
|
425 | ||||
|
426 | def help_all_output_test(subcommand=''): | |||
|
427 | """test that `ipython [subcommand] --help-all` works""" | |||
|
428 | cmd = ' '.join(get_ipython_cmd() + [subcommand, '--help-all']) | |||
|
429 | out, err, rc = get_output_error_code(cmd) | |||
|
430 | nt.assert_equal(rc, 0, err) | |||
|
431 | nt.assert_not_in("Traceback", err) | |||
|
432 | nt.assert_in("Options", out) | |||
|
433 | nt.assert_in("Class parameters", out) | |||
|
434 | return out, err | |||
|
435 |
General Comments 0
You need to be logged in to leave comments.
Login now