Show More
@@ -2649,9 +2649,9 class InteractiveShell(SingletonConfigurable): | |||
|
2649 | 2649 | def get_cells(): |
|
2650 | 2650 | """generator for sequence of code blocks to run""" |
|
2651 | 2651 | if fname.endswith('.ipynb'): |
|
2652 |
from IPython.nbformat import |
|
|
2653 | with open(fname) as f: | |
|
2654 |
nb = |
|
|
2652 | from IPython.nbformat import read | |
|
2653 | with io_open(fname) as f: | |
|
2654 | nb = read(f, as_version=4) | |
|
2655 | 2655 | if not nb.cells: |
|
2656 | 2656 | return |
|
2657 | 2657 | for cell in nb.cells: |
@@ -596,14 +596,16 Defaulting color scheme to 'NoColor'""" | |||
|
596 | 596 | """ |
|
597 | 597 | args = magic_arguments.parse_argstring(self.notebook, s) |
|
598 | 598 | |
|
599 |
from IPython.nbformat import |
|
|
599 | from IPython.nbformat import write, v4 | |
|
600 | 600 | args.filename = unquote_filename(args.filename) |
|
601 | 601 | if args.export: |
|
602 | 602 | cells = [] |
|
603 | 603 | hist = list(self.shell.history_manager.get_range()) |
|
604 |
for session, |
|
|
605 |
cells.append( |
|
|
606 | input=input)) | |
|
607 | nb = current.new_notebook(cells=cells) | |
|
604 | for session, execution_count, input in hist[:-1]: | |
|
605 | cells.append(v4.new_code_cell( | |
|
606 | execution_count=execution_count, | |
|
607 | source=source | |
|
608 | )) | |
|
609 | nb = v4.new_notebook(cells=cells) | |
|
608 | 610 | with io.open(args.filename, 'w', encoding='utf-8') as f: |
|
609 |
|
|
|
611 | write(f, nb, version=4) |
@@ -5,10 +5,6 Needs to be run by nose (to make ipython session available). | |||
|
5 | 5 | """ |
|
6 | 6 | from __future__ import absolute_import |
|
7 | 7 | |
|
8 | #----------------------------------------------------------------------------- | |
|
9 | # Imports | |
|
10 | #----------------------------------------------------------------------------- | |
|
11 | ||
|
12 | 8 | import io |
|
13 | 9 | import os |
|
14 | 10 | import sys |
@@ -40,9 +36,6 if py3compat.PY3: | |||
|
40 | 36 | else: |
|
41 | 37 | from StringIO import StringIO |
|
42 | 38 | |
|
43 | #----------------------------------------------------------------------------- | |
|
44 | # Test functions begin | |
|
45 | #----------------------------------------------------------------------------- | |
|
46 | 39 | |
|
47 | 40 | @magic.magics_class |
|
48 | 41 | class DummyMagics(magic.Magics): pass |
@@ -624,7 +617,7 def test_extension(): | |||
|
624 | 617 | |
|
625 | 618 | |
|
626 | 619 | # The nose skip decorator doesn't work on classes, so this uses unittest's skipIf |
|
627 |
@skipIf(dec.module_not_available('IPython.nbformat |
|
|
620 | @skipIf(dec.module_not_available('IPython.nbformat'), 'nbformat not importable') | |
|
628 | 621 | class NotebookExportMagicTests(TestCase): |
|
629 | 622 | def test_notebook_export_json(self): |
|
630 | 623 | with TemporaryDirectory() as td: |
@@ -7,11 +7,12 will be kept in this separate file. This makes it easier to aggregate in one | |||
|
7 | 7 | place the tricks needed to handle it; most other magics are much easier to test |
|
8 | 8 | and we do so in a common test_magic file. |
|
9 | 9 | """ |
|
10 | ||
|
11 | # Copyright (c) IPython Development Team. | |
|
12 | # Distributed under the terms of the Modified BSD License. | |
|
13 | ||
|
10 | 14 | from __future__ import absolute_import |
|
11 | 15 | |
|
12 | #----------------------------------------------------------------------------- | |
|
13 | # Imports | |
|
14 | #----------------------------------------------------------------------------- | |
|
15 | 16 | |
|
16 | 17 | import functools |
|
17 | 18 | import os |
@@ -32,9 +33,6 from IPython.utils.io import capture_output | |||
|
32 | 33 | from IPython.utils.tempdir import TemporaryDirectory |
|
33 | 34 | from IPython.core import debugger |
|
34 | 35 | |
|
35 | #----------------------------------------------------------------------------- | |
|
36 | # Test functions begin | |
|
37 | #----------------------------------------------------------------------------- | |
|
38 | 36 | |
|
39 | 37 | def doctest_refbug(): |
|
40 | 38 | """Very nasty problem with references held by multiple runs of a script. |
@@ -372,17 +370,17 tclass.py: deleting object: C-third | |||
|
372 | 370 | with tt.AssertNotPrints('SystemExit'): |
|
373 | 371 | _ip.magic('run -e %s' % self.fname) |
|
374 | 372 | |
|
375 |
@dec.skip_without('IPython.nbformat |
|
|
373 | @dec.skip_without('IPython.nbformat') # Requires jsonschema | |
|
376 | 374 | def test_run_nb(self): |
|
377 | 375 | """Test %run notebook.ipynb""" |
|
378 |
from IPython.nbformat import |
|
|
379 |
nb = |
|
|
376 | from IPython.nbformat import v4, writes | |
|
377 | nb = v4.new_notebook( | |
|
380 | 378 | cells=[ |
|
381 |
|
|
|
382 |
|
|
|
379 | v4.new_markdown_cell("The Ultimate Question of Everything"), | |
|
380 | v4.new_code_cell("answer=42") | |
|
383 | 381 | ] |
|
384 | 382 | ) |
|
385 |
src = |
|
|
383 | src = writes(nb, version=4) | |
|
386 | 384 | self.mktmp(src, ext='.ipynb') |
|
387 | 385 | |
|
388 | 386 | _ip.magic("run %s" % self.fname) |
@@ -1,23 +1,11 | |||
|
1 | 1 | """Test help output of various IPython entry points""" |
|
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 | #----------------------------------------------------------------------------- | |
|
3 | # Copyright (c) IPython Development Team. | |
|
4 | # Distributed under the terms of the Modified BSD License. | |
|
13 | 5 | |
|
14 | 6 | import IPython.testing.tools as tt |
|
15 | 7 | from IPython.testing.decorators import skip_without |
|
16 | 8 | |
|
17 | #----------------------------------------------------------------------------- | |
|
18 | # Tests | |
|
19 | #----------------------------------------------------------------------------- | |
|
20 | ||
|
21 | 9 | |
|
22 | 10 | def test_ipython_help(): |
|
23 | 11 | tt.help_all_output_test() |
@@ -37,6 +25,6 def test_locate_help(): | |||
|
37 | 25 | def test_locate_profile_help(): |
|
38 | 26 | tt.help_all_output_test("locate profile") |
|
39 | 27 | |
|
40 |
@skip_without('IPython.nbformat |
|
|
28 | @skip_without('IPython.nbformat') # Requires jsonschema to be installed | |
|
41 | 29 | def test_trust_help(): |
|
42 | 30 | tt.help_all_output_test("trust") |
General Comments 0
You need to be logged in to leave comments.
Login now