##// END OF EJS Templates
Fix various test failures from then new magics API.
Fernando Perez -
Show More
@@ -884,6 +884,13 b' class HistoryMagics(Magics):'
884 if close_at_end:
884 if close_at_end:
885 outfile.close()
885 outfile.close()
886
886
887 # For a long time we've had %hist as well as %history
888 @line_magic
889 def hist(self, arg):
890 return self.history(arg)
891
892 hist.__doc__ = history.__doc__
893
887 @line_magic
894 @line_magic
888 def rep(self, arg):
895 def rep(self, arg):
889 r"""Repeat a command, or get command to input line for editing.
896 r"""Repeat a command, or get command to input line for editing.
@@ -199,9 +199,7 b' class MagicsManager(Configurable):'
199 validate_type(magic_type)
199 validate_type(magic_type)
200 magic_name = func.func_name if magic_name is None else magic_name
200 magic_name = func.func_name if magic_name is None else magic_name
201 setattr(self.user_magics, magic_name, func)
201 setattr(self.user_magics, magic_name, func)
202 newm, name = self.user_magics.new_magic(func, magic_type, magic_name)
202 _record_magic(self.magics, magic_type, magic_name, func)
203 _record_magic(self.magics, magic_type, name, newm)
204
205
203
206 def _define_magic(self, name, func):
204 def _define_magic(self, name, func):
207 """Support for deprecated API.
205 """Support for deprecated API.
@@ -320,8 +320,8 b' Defaulting color scheme to \'NoColor\'"""'
320 @line_magic
320 @line_magic
321 def quickref(self,arg):
321 def quickref(self,arg):
322 """ Show a quick reference sheet """
322 """ Show a quick reference sheet """
323 import IPython.core.usage
323 from IPython.core.usage import quick_reference
324 qr = IPython.core.usage.quick_reference + self.magic_magic('-brief')
324 qr = quick_reference + self.magic('-brief')
325 page.page(qr)
325 page.page(qr)
326
326
327 @line_magic
327 @line_magic
@@ -522,7 +522,7 b' Defaulting color scheme to \'NoColor\'"""'
522 "foo.ipynb" to "foo.json" do "%notebook -f json foo.ipynb". Possible
522 "foo.ipynb" to "foo.json" do "%notebook -f json foo.ipynb". Possible
523 formats include (json/ipynb, py).
523 formats include (json/ipynb, py).
524 """
524 """
525 args = magic_arguments.parse_argstring(self.magic_notebook, s)
525 args = magic_arguments.parse_argstring(self.notebook, s)
526
526
527 from IPython.nbformat import current
527 from IPython.nbformat import current
528 args.filename = unquote_filename(args.filename)
528 args.filename = unquote_filename(args.filename)
@@ -1408,7 +1408,7 b' class NamespaceMagics(Magics):'
1408 beta
1408 beta
1409 """
1409 """
1410
1410
1411 varlist = self.magic_who_ls(parameter_s)
1411 varlist = self.who_ls(parameter_s)
1412 if not varlist:
1412 if not varlist:
1413 if parameter_s:
1413 if parameter_s:
1414 print 'No variables match your requested type.'
1414 print 'No variables match your requested type.'
@@ -1459,7 +1459,7 b' class NamespaceMagics(Magics):'
1459 beta str test
1459 beta str test
1460 """
1460 """
1461
1461
1462 varnames = self.magic_who_ls(parameter_s)
1462 varnames = self.who_ls(parameter_s)
1463 if not varnames:
1463 if not varnames:
1464 if parameter_s:
1464 if parameter_s:
1465 print 'No variables match your requested type.'
1465 print 'No variables match your requested type.'
@@ -16,6 +16,8 b' from StringIO import StringIO'
16
16
17 import nose.tools as nt
17 import nose.tools as nt
18
18
19 from IPython.core import magic
20 from IPython.core import magic_functions as mf
19 from IPython.nbformat.v3.tests.nbexamples import nb0
21 from IPython.nbformat.v3.tests.nbexamples import nb0
20 from IPython.nbformat import current
22 from IPython.nbformat import current
21 from IPython.testing import decorators as dec
23 from IPython.testing import decorators as dec
@@ -51,7 +53,8 b' def test_magic_parse_options():'
51 """Test that we don't mangle paths when parsing magic options."""
53 """Test that we don't mangle paths when parsing magic options."""
52 ip = get_ipython()
54 ip = get_ipython()
53 path = 'c:\\x'
55 path = 'c:\\x'
54 opts = ip._magic.parse_options('-f %s' % path,'f:')[0]
56 m = magic.Magics(ip)
57 opts = m.parse_options('-f %s' % path,'f:')[0]
55 # argv splitting is os-dependent
58 # argv splitting is os-dependent
56 if os.name == 'posix':
59 if os.name == 'posix':
57 expected = 'c:x'
60 expected = 'c:x'
@@ -284,8 +287,9 b' def test_parse_options():'
284 """Tests for basic options parsing in magics."""
287 """Tests for basic options parsing in magics."""
285 # These are only the most minimal of tests, more should be added later. At
288 # These are only the most minimal of tests, more should be added later. At
286 # the very least we check that basic text/unicode calls work OK.
289 # the very least we check that basic text/unicode calls work OK.
287 nt.assert_equal(_ip._magic.parse_options('foo', '')[1], 'foo')
290 m = magic.Magics(ip)
288 nt.assert_equal(_ip._magic.parse_options(u'foo', '')[1], u'foo')
291 nt.assert_equal(m.parse_options('foo', '')[1], 'foo')
292 nt.assert_equal(m.parse_options(u'foo', '')[1], u'foo')
289
293
290
294
291 def test_dirops():
295 def test_dirops():
@@ -422,7 +426,8 b' def test_timeit_arguments():'
422 "Test valid timeit arguments, should not cause SyntaxError (GH #1269)"
426 "Test valid timeit arguments, should not cause SyntaxError (GH #1269)"
423 _ip.magic("timeit ('#')")
427 _ip.magic("timeit ('#')")
424
428
425 @dec.skipif(_ip._magic.magic_prun == _ip._magic.profile_missing_notice)
429
430 @dec.skipif(mf.profile is None)
426 def test_prun_quotes():
431 def test_prun_quotes():
427 "Test that prun does not clobber string escapes (GH #1302)"
432 "Test that prun does not clobber string escapes (GH #1302)"
428 _ip.magic("prun -q x = '\t'")
433 _ip.magic("prun -q x = '\t'")
@@ -79,7 +79,7 b' def test_issue_114():'
79 msp = ip.prefilter_manager.multi_line_specials
79 msp = ip.prefilter_manager.multi_line_specials
80 ip.prefilter_manager.multi_line_specials = False
80 ip.prefilter_manager.multi_line_specials = False
81 try:
81 try:
82 for mgk in ip._magic.lsmagic():
82 for mgk in ip.magics_manager.lsmagic()['line']:
83 raw = template % mgk
83 raw = template % mgk
84 yield nt.assert_equals(ip.prefilter(raw), raw)
84 yield nt.assert_equals(ip.prefilter(raw), raw)
85 finally:
85 finally:
General Comments 0
You need to be logged in to leave comments. Login now