##// END OF EJS Templates
Merge pull request #8255 from minrk/testing-tools...
Min RK -
r21152:da7c86a3 merge
parent child Browse files
Show More
@@ -0,0 +1,2 b''
1 from .nbconvertapp import launch_new_instance
2 launch_new_instance()
@@ -0,0 +1,40 b''
1 import sys
2 import nose.tools as nt
3
4 from subprocess import Popen, PIPE
5
6 def get_output_error_code(cmd):
7 """Get stdout, stderr, and exit code from running a command"""
8 p = Popen(cmd, stdout=PIPE, stderr=PIPE)
9 out, err = p.communicate()
10 out = out.decode('utf8', 'replace')
11 err = err.decode('utf8', 'replace')
12 return out, err, p.returncode
13
14
15 def check_help_output(pkg, subcommand=None):
16 """test that `python -m PKG [subcommand] -h` works"""
17 cmd = [sys.executable, '-m', pkg]
18 if subcommand:
19 cmd.extend(subcommand)
20 cmd.append('-h')
21 out, err, rc = get_output_error_code(cmd)
22 nt.assert_equal(rc, 0, err)
23 nt.assert_not_in("Traceback", err)
24 nt.assert_in("Options", out)
25 nt.assert_in("--help-all", out)
26 return out, err
27
28
29 def check_help_all_output(pkg, subcommand=None):
30 """test that `python -m PKG --help-all` works"""
31 cmd = [sys.executable, '-m', pkg]
32 if subcommand:
33 cmd.extend(subcommand)
34 cmd.append('--help-all')
35 out, err, rc = get_output_error_code(cmd)
36 nt.assert_equal(rc, 0, err)
37 nt.assert_not_in("Traceback", err)
38 nt.assert_in("Options", out)
39 nt.assert_in("Class parameters", out)
40 return out, err
@@ -7,13 +7,18 b''
7 import glob
7 import glob
8 import os
8 import os
9 import re
9 import re
10 import sys
10 import tarfile
11 import tarfile
11 import zipfile
12 import zipfile
12 from io import BytesIO
13 from io import BytesIO, StringIO
13 from os.path import basename, join as pjoin
14 from os.path import basename, join as pjoin
14 from unittest import TestCase
15 from unittest import TestCase
15
16
16 import IPython.testing.tools as tt
17 try:
18 from unittest import mock
19 except ImportError:
20 import mock # py2
21
17 import IPython.testing.decorators as dec
22 import IPython.testing.decorators as dec
18 from IPython.utils import py3compat
23 from IPython.utils import py3compat
19 from IPython.utils.tempdir import TemporaryDirectory
24 from IPython.utils.tempdir import TemporaryDirectory
@@ -213,8 +218,13 b' class TestInstallNBExtension(TestCase):'
213 self.assertEqual(new_mtime, old_mtime)
218 self.assertEqual(new_mtime, old_mtime)
214
219
215 def test_quiet(self):
220 def test_quiet(self):
216 with tt.AssertNotPrints(re.compile(r'.+')):
221 stdout = StringIO()
222 stderr = StringIO()
223 with mock.patch.object(sys, 'stdout', stdout), \
224 mock.patch.object(sys, 'stderr', stderr):
217 install_nbextension(self.src, verbose=0)
225 install_nbextension(self.src, verbose=0)
226 self.assertEqual(stdout.getvalue(), '')
227 self.assertEqual(stderr.getvalue(), '')
218
228
219 def test_install_zip(self):
229 def test_install_zip(self):
220 path = pjoin(self.src, "myjsext.zip")
230 path = pjoin(self.src, "myjsext.zip")
@@ -1,15 +1,5 b''
1 """Test NotebookApp"""
1 """Test NotebookApp"""
2
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
3
14 import logging
4 import logging
15 import os
5 import os
@@ -17,19 +7,17 b' from tempfile import NamedTemporaryFile'
17
7
18 import nose.tools as nt
8 import nose.tools as nt
19
9
10 from traitlets.tests.utils import check_help_all_output
11
20 from IPython.utils.tempdir import TemporaryDirectory
12 from IPython.utils.tempdir import TemporaryDirectory
21 from IPython.utils.traitlets import TraitError
13 from IPython.utils.traitlets import TraitError
22 import IPython.testing.tools as tt
23 from IPython.html import notebookapp
14 from IPython.html import notebookapp
24 NotebookApp = notebookapp.NotebookApp
15 NotebookApp = notebookapp.NotebookApp
25
16
26 #-----------------------------------------------------------------------------
27 # Test functions
28 #-----------------------------------------------------------------------------
29
17
30 def test_help_output():
18 def test_help_output():
31 """ipython notebook --help-all works"""
19 """ipython notebook --help-all works"""
32 tt.help_all_output_test('notebook')
20 check_help_all_output('IPython.html')
33
21
34 def test_server_info_file():
22 def test_server_info_file():
35 nbapp = NotebookApp(profile='nbserver_file_test', log=logging.getLogger())
23 nbapp = NotebookApp(profile='nbserver_file_test', log=logging.getLogger())
@@ -1,31 +1,21 b''
1 """Test HTML utils"""
1 """Test HTML utils"""
2
2
3 #-----------------------------------------------------------------------------
3 # Copyright (c) Jupyter Development Team.
4 # Copyright (C) 2013 The IPython Development Team
4 # Distributed under the terms of the Modified BSD License.
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
5
14 import os
6 import os
15
7
16 import nose.tools as nt
8 import nose.tools as nt
17
9
18 import IPython.testing.tools as tt
10 from traitlets.tests.utils import check_help_all_output
19 from IPython.html.utils import url_escape, url_unescape, is_hidden
11 from IPython.html.utils import url_escape, url_unescape, is_hidden
20 from IPython.utils.tempdir import TemporaryDirectory
12 from IPython.utils.tempdir import TemporaryDirectory
21
13
22 #-----------------------------------------------------------------------------
23 # Test functions
24 #-----------------------------------------------------------------------------
25
14
26 def test_help_output():
15 def test_help_output():
27 """ipython notebook --help-all works"""
16 """jupyter notebook --help-all works"""
28 tt.help_all_output_test('notebook')
17 # FIXME: will be jupyter_notebook
18 check_help_all_output('IPython.html')
29
19
30
20
31 def test_url_escape():
21 def test_url_escape():
@@ -465,23 +465,3 b" def help_all_output_test(subcommand=''):"
465 nt.assert_in("Class parameters", out)
465 nt.assert_in("Class parameters", out)
466 return out, err
466 return out, err
467
467
468 def assert_big_text_equal(a, b, chunk_size=80):
469 """assert that large strings are equal
470
471 Zooms in on first chunk that differs,
472 to give better info than vanilla assertEqual for large text blobs.
473 """
474 for i in range(0, len(a), chunk_size):
475 chunk_a = a[i:i + chunk_size]
476 chunk_b = b[i:i + chunk_size]
477 nt.assert_equal(chunk_a, chunk_b, "[offset: %i]\n%r != \n%r" % (
478 i, chunk_a, chunk_b))
479
480 if len(a) > len(b):
481 nt.fail("Length doesn't match (%i > %i). Extra text:\n%r" % (
482 len(a), len(b), a[len(b):]
483 ))
484 elif len(a) < len(b):
485 nt.fail("Length doesn't match (%i < %i). Extra text:\n%r" % (
486 len(a), len(b), b[len(a):]
487 ))
@@ -1,28 +1,15 b''
1 """Tests for two-process terminal frontend
1 """Tests for two-process terminal frontend"""
2
2
3 Currently only has the most simple test possible, starting a console and running
3 # Copyright (c) Jupyter Development Team.
4 a single command.
4 # Distributed under the terms of the Modified BSD License.
5
6 Authors:
7
8 * Min RK
9 """
10
11 #-----------------------------------------------------------------------------
12 # Imports
13 #-----------------------------------------------------------------------------
14
5
15 import sys
6 import sys
16
7
17 from nose import SkipTest
8 from nose import SkipTest
18
9
19 import IPython.testing.tools as tt
10 from traitlets.tests.utils import check_help_all_output
20 from IPython.testing import decorators as dec
11 from IPython.testing import decorators as dec
21
12
22 #-----------------------------------------------------------------------------
23 # Tests
24 #-----------------------------------------------------------------------------
25
26 @dec.skip_win32
13 @dec.skip_win32
27 def test_console_starts():
14 def test_console_starts():
28 """test that `ipython console` starts a terminal"""
15 """test that `ipython console` starts a terminal"""
@@ -34,8 +21,7 b' def test_console_starts():'
34
21
35 def test_help_output():
22 def test_help_output():
36 """ipython console --help-all works"""
23 """ipython console --help-all works"""
37 tt.help_all_output_test('console')
24 check_help_all_output('jupyter_console')
38
39
25
40 def test_display_text():
26 def test_display_text():
41 "Ensure display protocol plain/text key is supported"
27 "Ensure display protocol plain/text key is supported"
@@ -14,7 +14,6 b' except ImportError:'
14 from IPython.kernel import KernelClient
14 from IPython.kernel import KernelClient
15 from IPython.terminal.console.interactiveshell import ZMQTerminalInteractiveShell
15 from IPython.terminal.console.interactiveshell import ZMQTerminalInteractiveShell
16 from IPython.utils.tempdir import TemporaryDirectory
16 from IPython.utils.tempdir import TemporaryDirectory
17 from IPython.testing.tools import monkeypatch
18 from IPython.testing.decorators import skip_without
17 from IPython.testing.decorators import skip_without
19 from IPython.utils.ipstruct import Struct
18 from IPython.utils.ipstruct import Struct
20
19
@@ -9,7 +9,7 b' from .base import ExportersTestsBase'
9 from ..notebook import NotebookExporter
9 from ..notebook import NotebookExporter
10
10
11 from IPython.nbformat import validate
11 from IPython.nbformat import validate
12 from IPython.testing.tools import assert_big_text_equal
12 from jupyter_nbconvert.tests.base import assert_big_text_equal
13
13
14 class TestNotebookExporter(ExportersTestsBase):
14 class TestNotebookExporter(ExportersTestsBase):
15 """Contains test functions for notebook.py"""
15 """Contains test functions for notebook.py"""
@@ -6,17 +6,17 b''
6 import io
6 import io
7 import os
7 import os
8 import glob
8 import glob
9 import shlex
9 import shutil
10 import shutil
11 import sys
10 import unittest
12 import unittest
11
13
14 import nose.tools as nt
15
12 from IPython.nbformat import v4, write
16 from IPython.nbformat import v4, write
13 from IPython.utils.tempdir import TemporaryWorkingDirectory
17 from IPython.utils.tempdir import TemporaryWorkingDirectory
14 from IPython.utils.process import get_output_error_code
18 from IPython.utils.process import get_output_error_code
15 from IPython.testing.tools import get_ipython_cmd
19 from IPython.utils.py3compat import string_types
16
17 # a trailing space allows for simpler concatenation with the other arguments
18 ipy_cmd = get_ipython_cmd(as_string=True) + " "
19
20
20
21 class TestsBase(unittest.TestCase):
21 class TestsBase(unittest.TestCase):
22 """Base tests class. Contains useful fuzzy comparison and nbconvert
22 """Base tests class. Contains useful fuzzy comparison and nbconvert
@@ -126,20 +126,43 b' class TestsBase(unittest.TestCase):'
126 return os.path.join(path, *names)
126 return os.path.join(path, *names)
127
127
128
128
129 def call(self, parameters, ignore_return_code=False):
129 def nbconvert(self, parameters, ignore_return_code=False):
130 """
130 """
131 Execute a, IPython shell command, listening for both Errors and non-zero
131 Run nbconvert a, IPython shell command, listening for both Errors and non-zero
132 return codes.
132 return codes.
133
133
134 Parameters
134 Parameters
135 ----------
135 ----------
136 parameters : str
136 parameters : str, list(str)
137 List of parameters to pass to IPython.
137 List of parameters to pass to IPython.
138 ignore_return_code : optional bool (default False)
138 ignore_return_code : optional bool (default False)
139 Throw an OSError if the return code
139 Throw an OSError if the return code
140 """
140 """
141
141 if isinstance(parameters, string_types):
142 stdout, stderr, retcode = get_output_error_code(ipy_cmd + parameters)
142 parameters = shlex.split(parameters)
143 cmd = [sys.executable, '-m', 'jupyter_nbconvert'] + parameters
144 stdout, stderr, retcode = get_output_error_code(cmd)
143 if not (retcode == 0 or ignore_return_code):
145 if not (retcode == 0 or ignore_return_code):
144 raise OSError(stderr)
146 raise OSError(stderr)
145 return stdout, stderr
147 return stdout, stderr
148
149 def assert_big_text_equal(a, b, chunk_size=80):
150 """assert that large strings are equal
151
152 Zooms in on first chunk that differs,
153 to give better info than vanilla assertEqual for large text blobs.
154 """
155 for i in range(0, len(a), chunk_size):
156 chunk_a = a[i:i + chunk_size]
157 chunk_b = b[i:i + chunk_size]
158 nt.assert_equal(chunk_a, chunk_b, "[offset: %i]\n%r != \n%r" % (
159 i, chunk_a, chunk_b))
160
161 if len(a) > len(b):
162 nt.fail("Length doesn't match (%i > %i). Extra text:\n%r" % (
163 len(a), len(b), a[len(b):]
164 ))
165 elif len(a) < len(b):
166 nt.fail("Length doesn't match (%i < %i). Extra text:\n%r" % (
167 len(a), len(b), b[len(a):]
168 ))
@@ -11,7 +11,7 b' import sys'
11 from .base import TestsBase
11 from .base import TestsBase
12 from ..postprocessors import PostProcessorBase
12 from ..postprocessors import PostProcessorBase
13
13
14 import IPython.testing.tools as tt
14 from traitlets.tests.utils import check_help_all_output
15 from IPython.testing import decorators as dec
15 from IPython.testing import decorators as dec
16
16
17 #-----------------------------------------------------------------------------
17 #-----------------------------------------------------------------------------
@@ -29,19 +29,19 b' class TestNbConvertApp(TestsBase):'
29 def test_notebook_help(self):
29 def test_notebook_help(self):
30 """Will help show if no notebooks are specified?"""
30 """Will help show if no notebooks are specified?"""
31 with self.create_temp_cwd():
31 with self.create_temp_cwd():
32 out, err = self.call('nbconvert --log-level 0', ignore_return_code=True)
32 out, err = self.nbconvert('--log-level 0', ignore_return_code=True)
33 self.assertIn("see '--help-all'", out)
33 self.assertIn("see '--help-all'", out)
34
34
35 def test_help_output(self):
35 def test_help_output(self):
36 """ipython nbconvert --help-all works"""
36 """ipython nbconvert --help-all works"""
37 tt.help_all_output_test('nbconvert')
37 check_help_all_output('jupyter_nbconvert')
38
38
39 def test_glob(self):
39 def test_glob(self):
40 """
40 """
41 Do search patterns work for notebook names?
41 Do search patterns work for notebook names?
42 """
42 """
43 with self.create_temp_cwd(['notebook*.ipynb']):
43 with self.create_temp_cwd(['notebook*.ipynb']):
44 self.call('nbconvert --to python *.ipynb --log-level 0')
44 self.nbconvert('--to python *.ipynb --log-level 0')
45 assert os.path.isfile('notebook1.py')
45 assert os.path.isfile('notebook1.py')
46 assert os.path.isfile('notebook2.py')
46 assert os.path.isfile('notebook2.py')
47
47
@@ -52,7 +52,7 b' class TestNbConvertApp(TestsBase):'
52 """
52 """
53 with self.create_temp_cwd():
53 with self.create_temp_cwd():
54 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
54 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
55 self.call('nbconvert --to python --log-level 0 ' +
55 self.nbconvert('--to python --log-level 0 ' +
56 os.path.join('subdir', '*.ipynb'))
56 os.path.join('subdir', '*.ipynb'))
57 assert os.path.isfile('notebook1.py')
57 assert os.path.isfile('notebook1.py')
58 assert os.path.isfile('notebook2.py')
58 assert os.path.isfile('notebook2.py')
@@ -63,7 +63,7 b' class TestNbConvertApp(TestsBase):'
63 Do explicit notebook names work?
63 Do explicit notebook names work?
64 """
64 """
65 with self.create_temp_cwd(['notebook*.ipynb']):
65 with self.create_temp_cwd(['notebook*.ipynb']):
66 self.call('nbconvert --log-level 0 --to python notebook2')
66 self.nbconvert('--log-level 0 --to python notebook2')
67 assert not os.path.isfile('notebook1.py')
67 assert not os.path.isfile('notebook1.py')
68 assert os.path.isfile('notebook2.py')
68 assert os.path.isfile('notebook2.py')
69
69
@@ -76,7 +76,7 b' class TestNbConvertApp(TestsBase):'
76 """
76 """
77 with self.create_temp_cwd(['notebook2.ipynb']):
77 with self.create_temp_cwd(['notebook2.ipynb']):
78 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
78 os.rename('notebook2.ipynb', 'notebook with spaces.ipynb')
79 self.call('nbconvert --log-level 0 --to pdf'
79 self.nbconvert('--log-level 0 --to pdf'
80 ' "notebook with spaces"'
80 ' "notebook with spaces"'
81 ' --PDFExporter.latex_count=1'
81 ' --PDFExporter.latex_count=1'
82 ' --PDFExporter.verbose=True'
82 ' --PDFExporter.verbose=True'
@@ -86,7 +86,7 b' class TestNbConvertApp(TestsBase):'
86 def test_post_processor(self):
86 def test_post_processor(self):
87 """Do post processors work?"""
87 """Do post processors work?"""
88 with self.create_temp_cwd(['notebook1.ipynb']):
88 with self.create_temp_cwd(['notebook1.ipynb']):
89 out, err = self.call('nbconvert --log-level 0 --to python notebook1 '
89 out, err = self.nbconvert('--log-level 0 --to python notebook1 '
90 '--post jupyter_nbconvert.tests.test_nbconvertapp.DummyPost')
90 '--post jupyter_nbconvert.tests.test_nbconvertapp.DummyPost')
91 self.assertIn('Dummy:notebook1.py', out)
91 self.assertIn('Dummy:notebook1.py', out)
92
92
@@ -94,11 +94,11 b' class TestNbConvertApp(TestsBase):'
94 def test_spurious_cr(self):
94 def test_spurious_cr(self):
95 """Check for extra CR characters"""
95 """Check for extra CR characters"""
96 with self.create_temp_cwd(['notebook2.ipynb']):
96 with self.create_temp_cwd(['notebook2.ipynb']):
97 self.call('nbconvert --log-level 0 --to latex notebook2')
97 self.nbconvert('--log-level 0 --to latex notebook2')
98 assert os.path.isfile('notebook2.tex')
98 assert os.path.isfile('notebook2.tex')
99 with open('notebook2.tex') as f:
99 with open('notebook2.tex') as f:
100 tex = f.read()
100 tex = f.read()
101 self.call('nbconvert --log-level 0 --to html notebook2')
101 self.nbconvert('--log-level 0 --to html notebook2')
102 assert os.path.isfile('notebook2.html')
102 assert os.path.isfile('notebook2.html')
103 with open('notebook2.html') as f:
103 with open('notebook2.html') as f:
104 html = f.read()
104 html = f.read()
@@ -109,7 +109,7 b' class TestNbConvertApp(TestsBase):'
109 def test_png_base64_html_ok(self):
109 def test_png_base64_html_ok(self):
110 """Is embedded png data well formed in HTML?"""
110 """Is embedded png data well formed in HTML?"""
111 with self.create_temp_cwd(['notebook2.ipynb']):
111 with self.create_temp_cwd(['notebook2.ipynb']):
112 self.call('nbconvert --log-level 0 --to HTML '
112 self.nbconvert('--log-level 0 --to HTML '
113 'notebook2.ipynb --template full')
113 'notebook2.ipynb --template full')
114 assert os.path.isfile('notebook2.html')
114 assert os.path.isfile('notebook2.html')
115 with open('notebook2.html') as f:
115 with open('notebook2.html') as f:
@@ -121,7 +121,7 b' class TestNbConvertApp(TestsBase):'
121 Do export templates work?
121 Do export templates work?
122 """
122 """
123 with self.create_temp_cwd(['notebook2.ipynb']):
123 with self.create_temp_cwd(['notebook2.ipynb']):
124 self.call('nbconvert --log-level 0 --to slides '
124 self.nbconvert('--log-level 0 --to slides '
125 'notebook2.ipynb')
125 'notebook2.ipynb')
126 assert os.path.isfile('notebook2.slides.html')
126 assert os.path.isfile('notebook2.slides.html')
127 with open('notebook2.slides.html') as f:
127 with open('notebook2.slides.html') as f:
@@ -130,11 +130,11 b' class TestNbConvertApp(TestsBase):'
130 def test_output_ext(self):
130 def test_output_ext(self):
131 """test --output=outputfile[.ext]"""
131 """test --output=outputfile[.ext]"""
132 with self.create_temp_cwd(['notebook1.ipynb']):
132 with self.create_temp_cwd(['notebook1.ipynb']):
133 self.call('nbconvert --log-level 0 --to python '
133 self.nbconvert('--log-level 0 --to python '
134 'notebook1.ipynb --output nb.py')
134 'notebook1.ipynb --output nb.py')
135 assert os.path.exists('nb.py')
135 assert os.path.exists('nb.py')
136
136
137 self.call('nbconvert --log-level 0 --to python '
137 self.nbconvert('--log-level 0 --to python '
138 'notebook1.ipynb --output nb2')
138 'notebook1.ipynb --output nb2')
139 assert os.path.exists('nb2.py')
139 assert os.path.exists('nb2.py')
140
140
@@ -143,7 +143,7 b' class TestNbConvertApp(TestsBase):'
143 Can a search pattern be used along with matching explicit notebook names?
143 Can a search pattern be used along with matching explicit notebook names?
144 """
144 """
145 with self.create_temp_cwd(['notebook*.ipynb']):
145 with self.create_temp_cwd(['notebook*.ipynb']):
146 self.call('nbconvert --log-level 0 --to python '
146 self.nbconvert('--log-level 0 --to python '
147 '*.ipynb notebook1.ipynb notebook2.ipynb')
147 '*.ipynb notebook1.ipynb notebook2.ipynb')
148 assert os.path.isfile('notebook1.py')
148 assert os.path.isfile('notebook1.py')
149 assert os.path.isfile('notebook2.py')
149 assert os.path.isfile('notebook2.py')
@@ -154,7 +154,7 b' class TestNbConvertApp(TestsBase):'
154 Can explicit notebook names be used and then a matching search pattern?
154 Can explicit notebook names be used and then a matching search pattern?
155 """
155 """
156 with self.create_temp_cwd(['notebook*.ipynb']):
156 with self.create_temp_cwd(['notebook*.ipynb']):
157 self.call('nbconvert --log-level 0 --to=python '
157 self.nbconvert('--log-level 0 --to=python '
158 'notebook1.ipynb notebook2.ipynb *.ipynb')
158 'notebook1.ipynb notebook2.ipynb *.ipynb')
159 assert os.path.isfile('notebook1.py')
159 assert os.path.isfile('notebook1.py')
160 assert os.path.isfile('notebook2.py')
160 assert os.path.isfile('notebook2.py')
@@ -165,7 +165,7 b' class TestNbConvertApp(TestsBase):'
165 Does the default config work?
165 Does the default config work?
166 """
166 """
167 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
167 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
168 self.call('nbconvert --log-level 0')
168 self.nbconvert('--log-level 0')
169 assert os.path.isfile('notebook1.py')
169 assert os.path.isfile('notebook1.py')
170 assert not os.path.isfile('notebook2.py')
170 assert not os.path.isfile('notebook2.py')
171
171
@@ -177,7 +177,7 b' class TestNbConvertApp(TestsBase):'
177 with self.create_temp_cwd(['notebook*.ipynb',
177 with self.create_temp_cwd(['notebook*.ipynb',
178 'ipython_nbconvert_config.py',
178 'ipython_nbconvert_config.py',
179 'override.py']):
179 'override.py']):
180 self.call('nbconvert --log-level 0 --config="override.py"')
180 self.nbconvert('--log-level 0 --config="override.py"')
181 assert not os.path.isfile('notebook1.py')
181 assert not os.path.isfile('notebook1.py')
182 assert os.path.isfile('notebook2.py')
182 assert os.path.isfile('notebook2.py')
183
183
@@ -187,7 +187,7 b' class TestNbConvertApp(TestsBase):'
187 """
187 """
188 with self.create_temp_cwd():
188 with self.create_temp_cwd():
189 self.create_empty_notebook(u'nb1_análisis.ipynb')
189 self.create_empty_notebook(u'nb1_análisis.ipynb')
190 self.call('nbconvert --log-level 0 --to python nb1_*')
190 self.nbconvert('--log-level 0 --to python nb1_*')
191 assert os.path.isfile(u'nb1_análisis.py')
191 assert os.path.isfile(u'nb1_análisis.py')
192
192
193 @dec.onlyif_cmds_exist('pdflatex', 'pandoc')
193 @dec.onlyif_cmds_exist('pdflatex', 'pandoc')
@@ -197,7 +197,7 b' class TestNbConvertApp(TestsBase):'
197 """
197 """
198 with self.create_temp_cwd():
198 with self.create_temp_cwd():
199 self.create_empty_notebook(u'nb1_análisis.ipynb')
199 self.create_empty_notebook(u'nb1_análisis.ipynb')
200 self.call('nbconvert --log-level 0 --to pdf "nb1_*"'
200 self.nbconvert('--log-level 0 --to pdf "nb1_*"'
201 ' --PDFExporter.latex_count=1'
201 ' --PDFExporter.latex_count=1'
202 ' --PDFExporter.verbose=True')
202 ' --PDFExporter.verbose=True')
203 assert os.path.isfile(u'nb1_análisis.pdf')
203 assert os.path.isfile(u'nb1_análisis.pdf')
@@ -208,7 +208,7 b' class TestNbConvertApp(TestsBase):'
208 """
208 """
209 with self.create_temp_cwd(['hello.py']):
209 with self.create_temp_cwd(['hello.py']):
210 self.create_empty_notebook(u'empty.ipynb')
210 self.create_empty_notebook(u'empty.ipynb')
211 self.call('nbconvert empty --to html --NbConvertApp.writer_class=\'hello.HelloWriter\'')
211 self.nbconvert('empty --to html --NbConvertApp.writer_class=\'hello.HelloWriter\'')
212 assert os.path.isfile(u'hello.txt')
212 assert os.path.isfile(u'hello.txt')
213
213
214 def test_output_suffix(self):
214 def test_output_suffix(self):
@@ -217,7 +217,7 b' class TestNbConvertApp(TestsBase):'
217 """
217 """
218 with self.create_temp_cwd():
218 with self.create_temp_cwd():
219 self.create_empty_notebook('empty.ipynb')
219 self.create_empty_notebook('empty.ipynb')
220 self.call('nbconvert empty.ipynb --to notebook')
220 self.nbconvert('empty.ipynb --to notebook')
221 assert os.path.isfile('empty.nbconvert.ipynb')
221 assert os.path.isfile('empty.nbconvert.ipynb')
222
222
223 def test_different_build_dir(self):
223 def test_different_build_dir(self):
@@ -227,8 +227,8 b' class TestNbConvertApp(TestsBase):'
227 with self.create_temp_cwd():
227 with self.create_temp_cwd():
228 self.create_empty_notebook('empty.ipynb')
228 self.create_empty_notebook('empty.ipynb')
229 os.mkdir('output')
229 os.mkdir('output')
230 self.call(
230 self.nbconvert(
231 'nbconvert empty.ipynb --to notebook '
231 'empty.ipynb --to notebook '
232 '--FilesWriter.build_directory=output')
232 '--FilesWriter.build_directory=output')
233 assert os.path.isfile('output/empty.ipynb')
233 assert os.path.isfile('output/empty.ipynb')
234
234
@@ -238,6 +238,6 b' class TestNbConvertApp(TestsBase):'
238 """
238 """
239 with self.create_temp_cwd():
239 with self.create_temp_cwd():
240 self.create_empty_notebook('empty.ipynb')
240 self.create_empty_notebook('empty.ipynb')
241 self.call('nbconvert empty.ipynb --to notebook --inplace')
241 self.nbconvert('empty.ipynb --to notebook --inplace')
242 assert os.path.isfile('empty.ipynb')
242 assert os.path.isfile('empty.ipynb')
243 assert not os.path.isfile('empty.nbconvert.ipynb')
243 assert not os.path.isfile('empty.nbconvert.ipynb')
@@ -1,27 +1,15 b''
1 """Test QtConsoleApp"""
1 """Test QtConsoleApp"""
2
2
3 #-----------------------------------------------------------------------------
3 # Copyright (c) Jupyter Development Team.
4 # Copyright (C) 2013 The IPython Development Team
4 # Distributed under the terms of the Modified BSD License.
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
5
14 import nose.tools as nt
6 import nose.tools as nt
15
7
16 import IPython.testing.tools as tt
8 from traitlets.tests.utils import check_help_all_output
17 from IPython.testing.decorators import skip_if_no_x11
9 from IPython.testing.decorators import skip_if_no_x11
18
10
19 #-----------------------------------------------------------------------------
20 # Test functions
21 #-----------------------------------------------------------------------------
22
23 @skip_if_no_x11
11 @skip_if_no_x11
24 def test_help_output():
12 def test_help_output():
25 """ipython qtconsole --help-all works"""
13 """jupyter qtconsole --help-all works"""
26 tt.help_all_output_test('qtconsole')
14 check_help_all_output('jupyter_qtconsole')
27
15
General Comments 0
You need to be logged in to leave comments. Login now