##// END OF EJS Templates
test that `-h` and `--help-all` work for various IPython entry points...
MinRK -
Show More
@@ -0,0 +1,29 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 -h works"""
24 tt.help_output_test('notebook')
25
26 def test_help_all_output():
27 """ipython notebook --help-all works"""
28 tt.help_all_output_test('notebook')
29
@@ -0,0 +1,29 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 -h works"""
24 tt.help_output_test('qtconsole')
25
26 def test_help_all_output():
27 """ipython qtconsole --help-all works"""
28 tt.help_all_output_test('qtconsole')
29
@@ -0,0 +1,67 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 from IPython.testing.tools import help, help_all
15
16 #-----------------------------------------------------------------------------
17 # Tests
18 #-----------------------------------------------------------------------------
19
20
21 @help()
22 def test_ipython_help():
23 pass
24
25 @help_all()
26 def test_ipython_help_all():
27 pass
28
29 @help("profile")
30 def test_profile_help():
31 pass
32
33 @help_all("profile")
34 def test_profile_help_all():
35 pass
36
37 @help("profile list")
38 def test_profile_list_help():
39 pass
40
41 @help_all("profile list")
42 def test_profile_list_help_all():
43 pass
44
45 @help("profile create")
46 def test_profile_create_help():
47 pass
48
49 @help_all("profile create")
50 def test_profile_create_help_all():
51 pass
52
53 @help("locate")
54 def test_locate_help():
55 pass
56
57 @help_all("locate")
58 def test_locate_help_all():
59 pass
60
61 @help("locate profile")
62 def test_locate_profile_help():
63 pass
64
65 @help_all("locate profile")
66 def test_locate_profile_all():
67 pass
@@ -1,12 +1,10 b''
1 """
2 Contains tests for the nbconvertapp
3 """
1 """Test NbConvertApp"""
2
4 3 #-----------------------------------------------------------------------------
5 #Copyright (c) 2013, the IPython Development Team.
6 #
7 #Distributed under the terms of the Modified BSD License.
4 # Copyright (C) 2013 The IPython Development Team
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 17 from .base import TestsBase
20 18
19 import IPython.testing.tools as tt
21 20 from IPython.testing import decorators as dec
22 21
23
22
24 23 #-----------------------------------------------------------------------------
25 24 # Constants
26 25 #-----------------------------------------------------------------------------
@@ -35,13 +34,18 b' class TestNbConvertApp(TestsBase):'
35 34
36 35
37 36 def test_notebook_help(self):
38 """
39 Will help show if no notebooks are specified?
40 """
37 """Will help show if no notebooks are specified?"""
41 38 with self.create_temp_cwd():
42 39 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
43 assert "see '--help-all'" in out
40 self.assertIn("see '--help-all'", out)
41
42 def test_help_output(self):
43 """ipython nbconvert -h works"""
44 tt.help_output_test('nbconvert')
44 45
46 def test_help_all_output(self):
47 """ipython nbconvert --help-all works"""
48 tt.help_all_output_test('nbconvert')
45 49
46 50 def test_glob(self):
47 51 """
@@ -18,11 +18,12 b' import time'
18 18 import nose.tools as nt
19 19 from nose import SkipTest
20 20
21 import IPython.testing.tools as tt
21 22 from IPython.testing import decorators as dec
22 23 from IPython.utils import py3compat
23 24
24 25 #-----------------------------------------------------------------------------
25 # Test functions begin
26 # Tests
26 27 #-----------------------------------------------------------------------------
27 28
28 29 @dec.skip_win32
@@ -55,3 +56,12 b' def test_console_starts():'
55 56 p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t)
56 57 if p.isalive():
57 58 p.terminate()
59
60 def test_help_output():
61 """ipython console -h works"""
62 tt.help_output_test('console')
63
64 def test_help_all_output():
65 """ipython console --help-all works"""
66 tt.help_all_output_test('console')
67
@@ -8,7 +8,7 b' Authors'
8 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 13 # Distributed under the terms of the BSD License. The full license is in
14 14 # the file COPYING, distributed as part of this software.
@@ -18,6 +18,7 b' from __future__ import absolute_import'
18 18 # Imports
19 19 #-----------------------------------------------------------------------------
20 20
21 import inspect
21 22 import os
22 23 import re
23 24 import sys
@@ -37,6 +38,7 b' except ImportError:'
37 38 has_nose = False
38 39
39 40 from IPython.config.loader import Config
41 from IPython.utils.process import get_output_error_code
40 42 from IPython.utils.text import list_strings
41 43 from IPython.utils.io import temp_pyfile, Tee
42 44 from IPython.utils import py3compat
@@ -408,3 +410,56 b' def monkeypatch(obj, name, attr):'
408 410 setattr(obj, name, attr)
409 411 yield
410 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
436
437 def help(cmd=''):
438 """decorator for making a test for `ipython cmd -h`"""
439 def wrap_help_test(f):
440 def test_help_output():
441 out, err = help_output_test(cmd)
442 if inspect.getargspec(f).args:
443 return f(out, err)
444 else:
445 return f()
446 cmds = cmd + ' ' if cmd else ''
447 test_help_output.__doc__ = "ipython {cmds}--help-all works".format(cmds=cmds)
448
449 return test_help_output
450 return wrap_help_test
451
452
453 def help_all(cmd=''):
454 """decorator for making a test for `ipython [cmd] --help-all`"""
455 def wrap_help_test(f):
456 def test_help_output():
457 out, err = help_all_output_test(cmd)
458 if inspect.getargspec(f).args:
459 return f(out, err)
460 else:
461 return f()
462 cmds = cmd + ' ' if cmd else ''
463 test_help_output.__doc__ = "ipython {cmds}--help-all works".format(cmds=cmds)
464 return test_help_output
465 return wrap_help_test
General Comments 0
You need to be logged in to leave comments. Login now