##// END OF EJS Templates
Merge pull request #13546 from Carreau/cleanup-dep-magic...
Matthias Bussonnier -
r27553:3da1ce6e merge
parent child Browse files
Show More
@@ -43,11 +43,11 b' def test_alias_args_error():'
43 43
44 44 def test_alias_args_commented():
45 45 """Check that alias correctly ignores 'commented out' args"""
46 _ip.magic('alias commetarg echo this is %%s a commented out arg')
47
46 _ip.run_line_magic("alias", "commentarg echo this is %%s a commented out arg")
47
48 48 with capture_output() as cap:
49 _ip.run_cell('commetarg')
50
49 _ip.run_cell("commentarg")
50
51 51 # strip() is for pytest compat; testing via iptest patch IPython shell
52 52 # in testing.globalipapp and replace the system call which messed up the
53 53 # \r\n
@@ -56,36 +56,42 b' def test_handlers():'
56 56 ip.user_ns['autocallable'] = autocallable
57 57
58 58 # auto
59 ip.magic('autocall 0')
59 ip.run_line_magic("autocall", "0")
60 60 # Only explicit escapes or instances of IPyAutocallable should get
61 61 # expanded
62 run([
63 ('len "abc"', 'len "abc"'),
64 ('autocallable', 'autocallable()'),
65 # Don't add extra brackets (gh-1117)
66 ('autocallable()', 'autocallable()'),
67 ])
68 ip.magic('autocall 1')
69 run([
70 ('len "abc"', 'len("abc")'),
71 ('len "abc";', 'len("abc");'), # ; is special -- moves out of parens
72 # Autocall is turned off if first arg is [] and the object
73 # is both callable and indexable. Like so:
74 ('len [1,2]', 'len([1,2])'), # len doesn't support __getitem__...
75 ('call_idx [1]', 'call_idx [1]'), # call_idx *does*..
76 ('call_idx 1', 'call_idx(1)'),
77 ('len', 'len'), # only at 2 does it auto-call on single args
78 ])
79 ip.magic('autocall 2')
80 run([
81 ('len "abc"', 'len("abc")'),
82 ('len "abc";', 'len("abc");'),
83 ('len [1,2]', 'len([1,2])'),
84 ('call_idx [1]', 'call_idx [1]'),
85 ('call_idx 1', 'call_idx(1)'),
86 # This is what's different:
87 ('len', 'len()'), # only at 2 does it auto-call on single args
88 ])
89 ip.magic('autocall 1')
62 run(
63 [
64 ('len "abc"', 'len "abc"'),
65 ("autocallable", "autocallable()"),
66 # Don't add extra brackets (gh-1117)
67 ("autocallable()", "autocallable()"),
68 ]
69 )
70 ip.run_line_magic("autocall", "1")
71 run(
72 [
73 ('len "abc"', 'len("abc")'),
74 ('len "abc";', 'len("abc");'), # ; is special -- moves out of parens
75 # Autocall is turned off if first arg is [] and the object
76 # is both callable and indexable. Like so:
77 ("len [1,2]", "len([1,2])"), # len doesn't support __getitem__...
78 ("call_idx [1]", "call_idx [1]"), # call_idx *does*..
79 ("call_idx 1", "call_idx(1)"),
80 ("len", "len"), # only at 2 does it auto-call on single args
81 ]
82 )
83 ip.run_line_magic("autocall", "2")
84 run(
85 [
86 ('len "abc"', 'len("abc")'),
87 ('len "abc";', 'len("abc");'),
88 ("len [1,2]", "len([1,2])"),
89 ("call_idx [1]", "call_idx [1]"),
90 ("call_idx 1", "call_idx(1)"),
91 # This is what's different:
92 ("len", "len()"), # only at 2 does it auto-call on single args
93 ]
94 )
95 ip.run_line_magic("autocall", "1")
90 96
91 97 assert failures == []
@@ -52,13 +52,13 b' def test_history():'
52 52
53 53 # Check whether specifying a range beyond the end of the current
54 54 # session results in an error (gh-804)
55 ip.magic('%hist 2-500')
55 ip.run_line_magic("hist", "2-500")
56 56
57 57 # Check that we can write non-ascii characters to a file
58 ip.magic("%%hist -f %s" % (tmp_path / "test1"))
59 ip.magic("%%hist -pf %s" % (tmp_path / "test2"))
60 ip.magic("%%hist -nf %s" % (tmp_path / "test3"))
61 ip.magic("%%save %s 1-10" % (tmp_path / "test4"))
58 ip.run_line_magic("hist", "-f %s" % (tmp_path / "test1"))
59 ip.run_line_magic("hist", "-pf %s" % (tmp_path / "test2"))
60 ip.run_line_magic("hist", "-nf %s" % (tmp_path / "test3"))
61 ip.run_line_magic("save", "%s 1-10" % (tmp_path / "test4"))
62 62
63 63 # New session
64 64 ip.history_manager.reset()
@@ -124,7 +124,7 b' def test_history():'
124 124
125 125 # Cross testing: check that magic %save can get previous session.
126 126 testfilename = (tmp_path / "test.py").resolve()
127 ip.magic("save " + str(testfilename) + " ~1/1-3")
127 ip.run_line_magic("save", str(testfilename) + " ~1/1-3")
128 128 with io.open(testfilename, encoding="utf-8") as testfile:
129 129 assert testfile.read() == "# coding: utf-8\n" + "\n".join(hist) + "\n"
130 130
General Comments 0
You need to be logged in to leave comments. Login now