##// END OF EJS Templates
do not use .magic(...) that has been deprecated for a decade (#14566)
M Bussonnier -
r28950:ac9ed9c1 merge
parent child Browse files
Show More
@@ -472,7 +472,7 Currently the magic system has the following functions:""",
472 ptformatter.pprint = dstore.rc_pprint
472 ptformatter.pprint = dstore.rc_pprint
473 disp_formatter.active_types = dstore.rc_active_types
473 disp_formatter.active_types = dstore.rc_active_types
474
474
475 shell.magic('xmode ' + dstore.xmode)
475 shell.run_line_magic("xmode", dstore.xmode)
476
476
477 # mode here is the state before we switch; switch_doctest_mode takes
477 # mode here is the state before we switch; switch_doctest_mode takes
478 # the mode we're switching to.
478 # the mode we're switching to.
@@ -21,7 +21,7 def test_logstart_unicode():
21 logfname = os.path.join(tdir, "test_unicode.log")
21 logfname = os.path.join(tdir, "test_unicode.log")
22 _ip.run_cell("'abc€'")
22 _ip.run_cell("'abc€'")
23 try:
23 try:
24 _ip.magic("logstart -to %s" % logfname)
24 _ip.run_line_magic("logstart", "-to %s" % logfname)
25 _ip.run_cell("'abc€'")
25 _ip.run_cell("'abc€'")
26 finally:
26 finally:
27 _ip.logger.logstop()
27 _ip.logger.logstop()
@@ -827,7 +827,7 def test_prun_special_syntax():
827 @dec.skipif(execution.profile is None)
827 @dec.skipif(execution.profile is None)
828 def test_prun_quotes():
828 def test_prun_quotes():
829 "Test that prun does not clobber string escapes (GH #1302)"
829 "Test that prun does not clobber string escapes (GH #1302)"
830 _ip.magic(r"prun -q x = '\t'")
830 _ip.run_line_magic("prun", r"-q x = '\t'")
831 assert _ip.user_ns["x"] == "\t"
831 assert _ip.user_ns["x"] == "\t"
832
832
833
833
@@ -838,7 +838,7 def test_extension():
838 print(' ', p)
838 print(' ', p)
839 print('CWD', os.getcwd())
839 print('CWD', os.getcwd())
840
840
841 pytest.raises(ImportError, _ip.magic, "load_ext daft_extension")
841 pytest.raises(ImportError, _ip.run_line_magic, "load_ext", "daft_extension")
842 daft_path = os.path.join(os.path.dirname(__file__), "daft_extension")
842 daft_path = os.path.join(os.path.dirname(__file__), "daft_extension")
843 sys.path.insert(0, daft_path)
843 sys.path.insert(0, daft_path)
844 try:
844 try:
@@ -271,10 +271,10 class TestMagicRunSimple(tt.TempFileMixin):
271 "ip = get_ipython()\n"
271 "ip = get_ipython()\n"
272 "for i in range(5):\n"
272 "for i in range(5):\n"
273 " try:\n"
273 " try:\n"
274 " ip.magic(%r)\n"
274 " ip.run_line_magic(%r, %r)\n"
275 " except NameError as e:\n"
275 " except NameError as e:\n"
276 " print(i)\n"
276 " print(i)\n"
277 " break\n" % ("run " + empty.fname)
277 " break\n" % ("run", empty.fname)
278 )
278 )
279 self.mktmp(src)
279 self.mktmp(src)
280 _ip.run_line_magic("run", str(self.fname))
280 _ip.run_line_magic("run", str(self.fname))
@@ -339,7 +339,7 tclass.py: deleting object: C-third
339 """Check that files in odd encodings are accepted."""
339 """Check that files in odd encodings are accepted."""
340 mydir = os.path.dirname(__file__)
340 mydir = os.path.dirname(__file__)
341 na = os.path.join(mydir, "nonascii.py")
341 na = os.path.join(mydir, "nonascii.py")
342 _ip.magic('run "%s"' % na)
342 _ip.run_line_magic("run", na)
343 assert _ip.user_ns["u"] == "Ўт№Ф"
343 assert _ip.user_ns["u"] == "Ўт№Ф"
344
344
345 def test_run_py_file_attribute(self):
345 def test_run_py_file_attribute(self):
@@ -175,7 +175,8 class IndentationErrorTest(unittest.TestCase):
175
175
176 with tt.AssertPrints("IndentationError"):
176 with tt.AssertPrints("IndentationError"):
177 with tt.AssertPrints("zoom()", suppress=False):
177 with tt.AssertPrints("zoom()", suppress=False):
178 ip.magic('run %s' % fname)
178 ip.run_line_magic("run", fname)
179
179
180
180 @skip_without("pandas")
181 @skip_without("pandas")
181 def test_dynamic_code():
182 def test_dynamic_code():
@@ -237,7 +238,7 bar()
237 f.write(se_file_1)
238 f.write(se_file_1)
238
239
239 with tt.AssertPrints(["7/", "SyntaxError"]):
240 with tt.AssertPrints(["7/", "SyntaxError"]):
240 ip.magic("run " + fname)
241 ip.run_line_magic("run", fname)
241
242
242 # Modify the file
243 # Modify the file
243 with open(fname, "w", encoding="utf-8") as f:
244 with open(fname, "w", encoding="utf-8") as f:
@@ -245,7 +246,7 bar()
245
246
246 # The SyntaxError should point to the correct line
247 # The SyntaxError should point to the correct line
247 with tt.AssertPrints(["7/", "SyntaxError"]):
248 with tt.AssertPrints(["7/", "SyntaxError"]):
248 ip.magic("run " + fname)
249 ip.run_line_magic("run", fname)
249
250
250 def test_non_syntaxerror(self):
251 def test_non_syntaxerror(self):
251 # SyntaxTB may be called with an error other than a SyntaxError
252 # SyntaxTB may be called with an error other than a SyntaxError
General Comments 0
You need to be logged in to leave comments. Login now