diff --git a/IPython/html/tests/test_notebookapp.py b/IPython/html/tests/test_notebookapp.py new file mode 100644 index 0000000..24c0e62 --- /dev/null +++ b/IPython/html/tests/test_notebookapp.py @@ -0,0 +1,29 @@ +"""Test NotebookApp""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2013 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import nose.tools as nt + +import IPython.testing.tools as tt + +#----------------------------------------------------------------------------- +# Test functions +#----------------------------------------------------------------------------- + +def test_help_output(): + """ipython notebook -h works""" + tt.help_output_test('notebook') + +def test_help_all_output(): + """ipython notebook --help-all works""" + tt.help_all_output_test('notebook') + diff --git a/IPython/nbconvert/tests/test_nbconvertapp.py b/IPython/nbconvert/tests/test_nbconvertapp.py index 1eabe13..9e680f0 100644 --- a/IPython/nbconvert/tests/test_nbconvertapp.py +++ b/IPython/nbconvert/tests/test_nbconvertapp.py @@ -1,12 +1,10 @@ -""" -Contains tests for the nbconvertapp -""" +"""Test NbConvertApp""" + #----------------------------------------------------------------------------- -#Copyright (c) 2013, the IPython Development Team. -# -#Distributed under the terms of the Modified BSD License. +# Copyright (C) 2013 The IPython Development Team # -#The full license is in the file COPYING.txt, distributed with this software. +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. #----------------------------------------------------------------------------- #----------------------------------------------------------------------------- @@ -18,9 +16,10 @@ import glob from .base import TestsBase +import IPython.testing.tools as tt from IPython.testing import decorators as dec - + #----------------------------------------------------------------------------- # Constants #----------------------------------------------------------------------------- @@ -35,13 +34,18 @@ class TestNbConvertApp(TestsBase): def test_notebook_help(self): - """ - Will help show if no notebooks are specified? - """ + """Will help show if no notebooks are specified?""" with self.create_temp_cwd(): out, err = self.call('nbconvert --log-level 0', ignore_return_code=True) - assert "see '--help-all'" in out + self.assertIn("see '--help-all'", out) + + def test_help_output(self): + """ipython nbconvert -h works""" + tt.help_output_test('nbconvert') + def test_help_all_output(self): + """ipython nbconvert --help-all works""" + tt.help_all_output_test('nbconvert') def test_glob(self): """ diff --git a/IPython/qt/console/tests/test_app.py b/IPython/qt/console/tests/test_app.py new file mode 100644 index 0000000..8a8d446 --- /dev/null +++ b/IPython/qt/console/tests/test_app.py @@ -0,0 +1,29 @@ +"""Test QtConsoleApp""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2013 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +import nose.tools as nt + +import IPython.testing.tools as tt + +#----------------------------------------------------------------------------- +# Test functions +#----------------------------------------------------------------------------- + +def test_help_output(): + """ipython qtconsole -h works""" + tt.help_output_test('qtconsole') + +def test_help_all_output(): + """ipython qtconsole --help-all works""" + tt.help_all_output_test('qtconsole') + diff --git a/IPython/terminal/console/tests/test_console.py b/IPython/terminal/console/tests/test_console.py index 60b9679..ab09cec 100644 --- a/IPython/terminal/console/tests/test_console.py +++ b/IPython/terminal/console/tests/test_console.py @@ -18,11 +18,12 @@ import time import nose.tools as nt from nose import SkipTest +import IPython.testing.tools as tt from IPython.testing import decorators as dec from IPython.utils import py3compat #----------------------------------------------------------------------------- -# Test functions begin +# Tests #----------------------------------------------------------------------------- @dec.skip_win32 @@ -55,3 +56,12 @@ def test_console_starts(): p.expect([pexpect.EOF, pexpect.TIMEOUT], timeout=t) if p.isalive(): p.terminate() + +def test_help_output(): + """ipython console -h works""" + tt.help_output_test('console') + +def test_help_all_output(): + """ipython console --help-all works""" + tt.help_all_output_test('console') + diff --git a/IPython/terminal/tests/test_help.py b/IPython/terminal/tests/test_help.py new file mode 100644 index 0000000..f217e20 --- /dev/null +++ b/IPython/terminal/tests/test_help.py @@ -0,0 +1,67 @@ +"""Test help output of various IPython entry points""" + +#----------------------------------------------------------------------------- +# Copyright (C) 2013 The IPython Development Team +# +# Distributed under the terms of the BSD License. The full license is in +# the file COPYING, distributed as part of this software. +#----------------------------------------------------------------------------- + +#----------------------------------------------------------------------------- +# Imports +#----------------------------------------------------------------------------- + +from IPython.testing.tools import help, help_all + +#----------------------------------------------------------------------------- +# Tests +#----------------------------------------------------------------------------- + + +@help() +def test_ipython_help(): + pass + +@help_all() +def test_ipython_help_all(): + pass + +@help("profile") +def test_profile_help(): + pass + +@help_all("profile") +def test_profile_help_all(): + pass + +@help("profile list") +def test_profile_list_help(): + pass + +@help_all("profile list") +def test_profile_list_help_all(): + pass + +@help("profile create") +def test_profile_create_help(): + pass + +@help_all("profile create") +def test_profile_create_help_all(): + pass + +@help("locate") +def test_locate_help(): + pass + +@help_all("locate") +def test_locate_help_all(): + pass + +@help("locate profile") +def test_locate_profile_help(): + pass + +@help_all("locate profile") +def test_locate_profile_all(): + pass diff --git a/IPython/testing/tools.py b/IPython/testing/tools.py index 696c655..45c2034 100644 --- a/IPython/testing/tools.py +++ b/IPython/testing/tools.py @@ -8,7 +8,7 @@ Authors from __future__ import absolute_import #----------------------------------------------------------------------------- -# Copyright (C) 2009-2011 The IPython Development Team +# Copyright (C) 2009 The IPython Development Team # # Distributed under the terms of the BSD License. The full license is in # the file COPYING, distributed as part of this software. @@ -18,6 +18,7 @@ from __future__ import absolute_import # Imports #----------------------------------------------------------------------------- +import inspect import os import re import sys @@ -37,6 +38,7 @@ except ImportError: has_nose = False from IPython.config.loader import Config +from IPython.utils.process import get_output_error_code from IPython.utils.text import list_strings from IPython.utils.io import temp_pyfile, Tee from IPython.utils import py3compat @@ -408,3 +410,56 @@ def monkeypatch(obj, name, attr): setattr(obj, name, attr) yield setattr(obj, name, orig) + + +def help_output_test(subcommand=''): + """test that `ipython [subcommand] -h` works""" + cmd = ' '.join(get_ipython_cmd() + [subcommand, '-h']) + out, err, rc = get_output_error_code(cmd) + nt.assert_equal(rc, 0, err) + nt.assert_not_in("Traceback", err) + nt.assert_in("Options", out) + nt.assert_in("--help-all", out) + return out, err + + +def help_all_output_test(subcommand=''): + """test that `ipython [subcommand] --help-all` works""" + cmd = ' '.join(get_ipython_cmd() + [subcommand, '--help-all']) + out, err, rc = get_output_error_code(cmd) + nt.assert_equal(rc, 0, err) + nt.assert_not_in("Traceback", err) + nt.assert_in("Options", out) + nt.assert_in("Class parameters", out) + return out, err + + +def help(cmd=''): + """decorator for making a test for `ipython cmd -h`""" + def wrap_help_test(f): + def test_help_output(): + out, err = help_output_test(cmd) + if inspect.getargspec(f).args: + return f(out, err) + else: + return f() + cmds = cmd + ' ' if cmd else '' + test_help_output.__doc__ = "ipython {cmds}--help-all works".format(cmds=cmds) + + return test_help_output + return wrap_help_test + + +def help_all(cmd=''): + """decorator for making a test for `ipython [cmd] --help-all`""" + def wrap_help_test(f): + def test_help_output(): + out, err = help_all_output_test(cmd) + if inspect.getargspec(f).args: + return f(out, err) + else: + return f() + cmds = cmd + ' ' if cmd else '' + test_help_output.__doc__ = "ipython {cmds}--help-all works".format(cmds=cmds) + return test_help_output + return wrap_help_test