diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 7df9e29..a6b395e 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2649,9 +2649,9 @@ class InteractiveShell(SingletonConfigurable): def get_cells(): """generator for sequence of code blocks to run""" if fname.endswith('.ipynb'): - from IPython.nbformat import current - with open(fname) as f: - nb = current.read(f) + from IPython.nbformat import read + with io_open(fname) as f: + nb = read(f, as_version=4) if not nb.cells: return for cell in nb.cells: diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py index 52e032a..02974e6 100644 --- a/IPython/core/magics/basic.py +++ b/IPython/core/magics/basic.py @@ -596,14 +596,16 @@ Defaulting color scheme to 'NoColor'""" """ args = magic_arguments.parse_argstring(self.notebook, s) - from IPython.nbformat import current + from IPython.nbformat import write, v4 args.filename = unquote_filename(args.filename) if args.export: cells = [] hist = list(self.shell.history_manager.get_range()) - for session, prompt_number, input in hist[:-1]: - cells.append(current.new_code_cell(prompt_number=prompt_number, - input=input)) - nb = current.new_notebook(cells=cells) + for session, execution_count, input in hist[:-1]: + cells.append(v4.new_code_cell( + execution_count=execution_count, + source=source + )) + nb = v4.new_notebook(cells=cells) with io.open(args.filename, 'w', encoding='utf-8') as f: - current.write(nb, f) + write(f, nb, version=4) diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index e28dc5c..acd0d3d 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -5,10 +5,6 @@ Needs to be run by nose (to make ipython session available). """ from __future__ import absolute_import -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - import io import os import sys @@ -40,9 +36,6 @@ if py3compat.PY3: else: from StringIO import StringIO -#----------------------------------------------------------------------------- -# Test functions begin -#----------------------------------------------------------------------------- @magic.magics_class class DummyMagics(magic.Magics): pass @@ -624,7 +617,7 @@ def test_extension(): # The nose skip decorator doesn't work on classes, so this uses unittest's skipIf -@skipIf(dec.module_not_available('IPython.nbformat.current'), 'nbformat not importable') +@skipIf(dec.module_not_available('IPython.nbformat'), 'nbformat not importable') class NotebookExportMagicTests(TestCase): def test_notebook_export_json(self): with TemporaryDirectory() as td: diff --git a/IPython/core/tests/test_run.py b/IPython/core/tests/test_run.py index 95dc4ac..2316a3d 100644 --- a/IPython/core/tests/test_run.py +++ b/IPython/core/tests/test_run.py @@ -7,11 +7,12 @@ will be kept in this separate file. This makes it easier to aggregate in one place the tricks needed to handle it; most other magics are much easier to test and we do so in a common test_magic file. """ + +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. + from __future__ import absolute_import -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- import functools import os @@ -32,9 +33,6 @@ from IPython.utils.io import capture_output from IPython.utils.tempdir import TemporaryDirectory from IPython.core import debugger -#----------------------------------------------------------------------------- -# Test functions begin -#----------------------------------------------------------------------------- def doctest_refbug(): """Very nasty problem with references held by multiple runs of a script. @@ -372,17 +370,17 @@ tclass.py: deleting object: C-third with tt.AssertNotPrints('SystemExit'): _ip.magic('run -e %s' % self.fname) - @dec.skip_without('IPython.nbformat.current') # Requires jsonschema + @dec.skip_without('IPython.nbformat') # Requires jsonschema def test_run_nb(self): """Test %run notebook.ipynb""" - from IPython.nbformat import current - nb = current.new_notebook( + from IPython.nbformat import v4, writes + nb = v4.new_notebook( cells=[ - current.new_markdown_cell("The Ultimate Question of Everything"), - current.new_code_cell("answer=42") + v4.new_markdown_cell("The Ultimate Question of Everything"), + v4.new_code_cell("answer=42") ] ) - src = current.writes(nb) + src = writes(nb, version=4) self.mktmp(src, ext='.ipynb') _ip.magic("run %s" % self.fname) diff --git a/IPython/terminal/tests/test_help.py b/IPython/terminal/tests/test_help.py index fd197f8..262a375 100644 --- a/IPython/terminal/tests/test_help.py +++ b/IPython/terminal/tests/test_help.py @@ -1,23 +1,11 @@ """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 -#----------------------------------------------------------------------------- +# Copyright (c) IPython Development Team. +# Distributed under the terms of the Modified BSD License. import IPython.testing.tools as tt from IPython.testing.decorators import skip_without -#----------------------------------------------------------------------------- -# Tests -#----------------------------------------------------------------------------- - def test_ipython_help(): tt.help_all_output_test() @@ -37,6 +25,6 @@ def test_locate_help(): def test_locate_profile_help(): tt.help_all_output_test("locate profile") -@skip_without('IPython.nbformat.current') # Requires jsonschema to be installed +@skip_without('IPython.nbformat') # Requires jsonschema to be installed def test_trust_help(): tt.help_all_output_test("trust")