##// END OF EJS Templates
Modify tests to expect unicode. Now all tests pass again.
Thomas Kluyver -
Show More
@@ -370,7 +370,8 b' class ArgParseConfigLoader(CommandLineConfigLoader):'
370 for a in args:
370 for a in args:
371 if isinstance(a, str):
371 if isinstance(a, str):
372 # don't decode if we already got unicode
372 # don't decode if we already got unicode
373 a = a.decode(sys.stdin.encoding)
373 a = a.decode(sys.stdin.encoding or
374 sys.getdefaultencoding())
374 uargs.append(a)
375 uargs.append(a)
375 self.parsed_data, self.extra_args = self.parser.parse_known_args(uargs)
376 self.parsed_data, self.extra_args = self.parser.parse_known_args(uargs)
376
377
@@ -857,7 +857,7 b' class EscapedTransformer(object):'
857 elif line_info.esc == '??':
857 elif line_info.esc == '??':
858 pinfo = 'pinfo2'
858 pinfo = 'pinfo2'
859
859
860 tpl = '%sget_ipython().magic("%s %s")'
860 tpl = '%sget_ipython().magic(u"%s %s")'
861 return tpl % (line_info.lspace, pinfo,
861 return tpl % (line_info.lspace, pinfo,
862 ' '.join([line_info.fpart, line_info.rest]).strip())
862 ' '.join([line_info.fpart, line_info.rest]).strip())
863
863
@@ -68,10 +68,10 b' def test_handlers():'
68 # These are useful for checking a particular recursive alias issue
68 # These are useful for checking a particular recursive alias issue
69 ip.alias_manager.alias_table['top'] = (0, 'd:/cygwin/top')
69 ip.alias_manager.alias_table['top'] = (0, 'd:/cygwin/top')
70 ip.alias_manager.alias_table['d'] = (0, 'true')
70 ip.alias_manager.alias_table['d'] = (0, 'true')
71 run([("an_alias", 'get_ipython().system("true ")'), # alias
71 run([("an_alias", 'get_ipython().system(u"true ")'), # alias
72 # Below: recursive aliases should expand whitespace-surrounded
72 # Below: recursive aliases should expand whitespace-surrounded
73 # chars, *not* initial chars which happen to be aliases:
73 # chars, *not* initial chars which happen to be aliases:
74 ("top", 'get_ipython().system("d:/cygwin/top ")'),
74 ("top", 'get_ipython().system(u"d:/cygwin/top ")'),
75 ])
75 ])
76 ip.system = old_system_cmd
76 ip.system = old_system_cmd
77
77
@@ -82,15 +82,15 b' def test_handlers():'
82 # turns off the esc char, which it should unless there is a continuation
82 # turns off the esc char, which it should unless there is a continuation
83 # line.
83 # line.
84 run([('"no change"', '"no change"'), # normal
84 run([('"no change"', '"no change"'), # normal
85 ("!true", 'get_ipython().system("true")'), # shell_escapes
85 ("!true", 'get_ipython().system(u"true")'), # shell_escapes
86 ("!! true", 'get_ipython().magic("sx true")'), # shell_escapes + magic
86 ("!! true", 'get_ipython().magic(u"sx true")'), # shell_escapes + magic
87 ("!!true", 'get_ipython().magic("sx true")'), # shell_escapes + magic
87 ("!!true", 'get_ipython().magic(u"sx true")'), # shell_escapes + magic
88 ("%lsmagic", 'get_ipython().magic("lsmagic ")'), # magic
88 ("%lsmagic", 'get_ipython().magic(u"lsmagic ")'), # magic
89 ("lsmagic", 'get_ipython().magic("lsmagic ")'), # magic
89 ("lsmagic", 'get_ipython().magic(u"lsmagic ")'), # magic
90 #("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache
90 #("a = b # PYTHON-MODE", '_i'), # emacs -- avoids _in cache
91
91
92 # post-esc-char whitespace goes inside
92 # post-esc-char whitespace goes inside
93 ("! true", 'get_ipython().system(" true")'),
93 ("! true", 'get_ipython().system(u" true")'),
94
94
95 # handle_help
95 # handle_help
96
96
@@ -113,11 +113,11 b' def test_handlers():'
113 ip.prefilter_manager.multi_line_specials = True
113 ip.prefilter_manager.multi_line_specials = True
114 # initial indents must be preserved.
114 # initial indents must be preserved.
115 run([
115 run([
116 ('if 1:\n !true', 'if 1:\n get_ipython().system("true")'),
116 ('if 1:\n !true', 'if 1:\n get_ipython().system(u"true")'),
117 ('if 2:\n lsmagic', 'if 2:\n get_ipython().magic("lsmagic ")'),
117 ('if 2:\n lsmagic', 'if 2:\n get_ipython().magic(u"lsmagic ")'),
118 ('if 1:\n an_alias', 'if 1:\n get_ipython().system("true ")'),
118 ('if 1:\n an_alias', 'if 1:\n get_ipython().system(u"true ")'),
119 # Weird one
119 # Weird one
120 ('if 1:\n !!true', 'if 1:\n get_ipython().magic("sx true")'),
120 ('if 1:\n !!true', 'if 1:\n get_ipython().magic(u"sx true")'),
121
121
122 # Even with m_l_s on, autocall is off even with special chars
122 # Even with m_l_s on, autocall is off even with special chars
123 ('if 1:\n /fun 1 2', 'if 1:\n /fun 1 2'),
123 ('if 1:\n /fun 1 2', 'if 1:\n /fun 1 2'),
@@ -439,15 +439,15 b' def transform_checker(tests, func):'
439
439
440 syntax = \
440 syntax = \
441 dict(assign_system =
441 dict(assign_system =
442 [('a =! ls', 'a = get_ipython().getoutput("ls")'),
442 [('a =! ls', 'a = get_ipython().getoutput(u"ls")'),
443 ('b = !ls', 'b = get_ipython().getoutput("ls")'),
443 ('b = !ls', 'b = get_ipython().getoutput(u"ls")'),
444 ('x=1', 'x=1'), # normal input is unmodified
444 ('x=1', 'x=1'), # normal input is unmodified
445 (' ',' '), # blank lines are kept intact
445 (' ',' '), # blank lines are kept intact
446 ],
446 ],
447
447
448 assign_magic =
448 assign_magic =
449 [('a =% who', 'a = get_ipython().magic("who")'),
449 [('a =% who', 'a = get_ipython().magic(u"who")'),
450 ('b = %who', 'b = get_ipython().magic("who")'),
450 ('b = %who', 'b = get_ipython().magic(u"who")'),
451 ('x=1', 'x=1'), # normal input is unmodified
451 ('x=1', 'x=1'), # normal input is unmodified
452 (' ',' '), # blank lines are kept intact
452 (' ',' '), # blank lines are kept intact
453 ],
453 ],
@@ -474,29 +474,29 b' syntax = \\'
474
474
475 # System calls
475 # System calls
476 escaped_shell =
476 escaped_shell =
477 [ ('!ls', 'get_ipython().system("ls")'),
477 [ ('!ls', 'get_ipython().system(u"ls")'),
478 # Double-escape shell, this means to capture the output of the
478 # Double-escape shell, this means to capture the output of the
479 # subprocess and return it
479 # subprocess and return it
480 ('!!ls', 'get_ipython().getoutput("ls")'),
480 ('!!ls', 'get_ipython().getoutput(u"ls")'),
481 ],
481 ],
482
482
483 # Help/object info
483 # Help/object info
484 escaped_help =
484 escaped_help =
485 [ ('?', 'get_ipython().show_usage()'),
485 [ ('?', 'get_ipython().show_usage()'),
486 ('?x1', 'get_ipython().magic("pinfo x1")'),
486 ('?x1', 'get_ipython().magic(u"pinfo x1")'),
487 ('??x2', 'get_ipython().magic("pinfo2 x2")'),
487 ('??x2', 'get_ipython().magic(u"pinfo2 x2")'),
488 ('x3?', 'get_ipython().magic("pinfo x3")'),
488 ('x3?', 'get_ipython().magic(u"pinfo x3")'),
489 ('x4??', 'get_ipython().magic("pinfo2 x4")'),
489 ('x4??', 'get_ipython().magic(u"pinfo2 x4")'),
490 ('%hist?', 'get_ipython().magic("pinfo %hist")'),
490 ('%hist?', 'get_ipython().magic(u"pinfo %hist")'),
491 ('f*?', 'get_ipython().magic("psearch f*")'),
491 ('f*?', 'get_ipython().magic(u"psearch f*")'),
492 ('ax.*aspe*?', 'get_ipython().magic("psearch ax.*aspe*")'),
492 ('ax.*aspe*?', 'get_ipython().magic(u"psearch ax.*aspe*")'),
493 ],
493 ],
494
494
495 # Explicit magic calls
495 # Explicit magic calls
496 escaped_magic =
496 escaped_magic =
497 [ ('%cd', 'get_ipython().magic("cd")'),
497 [ ('%cd', 'get_ipython().magic(u"cd")'),
498 ('%cd /home', 'get_ipython().magic("cd /home")'),
498 ('%cd /home', 'get_ipython().magic(u"cd /home")'),
499 (' %magic', ' get_ipython().magic("magic")'),
499 (' %magic', ' get_ipython().magic(u"magic")'),
500 ],
500 ],
501
501
502 # Quoting with separate arguments
502 # Quoting with separate arguments
@@ -155,11 +155,11 b' Exception reporting mode: Plain'
155
155
156 In [18]: %run simpleerr.py exit
156 In [18]: %run simpleerr.py exit
157 An exception has occurred, use %tb to see the full traceback.
157 An exception has occurred, use %tb to see the full traceback.
158 SystemExit: (1, 'Mode = exit')
158 SystemExit: (1, u'Mode = exit')
159
159
160 In [19]: %run simpleerr.py exit 2
160 In [19]: %run simpleerr.py exit 2
161 An exception has occurred, use %tb to see the full traceback.
161 An exception has occurred, use %tb to see the full traceback.
162 SystemExit: (2, 'Mode = exit')
162 SystemExit: (2, u'Mode = exit')
163
163
164 In [20]: %tb
164 In [20]: %tb
165 Traceback (most recent call last):
165 Traceback (most recent call last):
@@ -169,7 +169,7 b' Traceback (most recent call last):'
169 sysexit(stat, mode)
169 sysexit(stat, mode)
170 File ... line 11, in sysexit
170 File ... line 11, in sysexit
171 raise SystemExit(stat, 'Mode = %s' % mode)
171 raise SystemExit(stat, 'Mode = %s' % mode)
172 SystemExit: (2, 'Mode = exit')
172 SystemExit: (2, u'Mode = exit')
173
173
174 In [21]: %xmode context
174 In [21]: %xmode context
175 Exception reporting mode: Context
175 Exception reporting mode: Context
@@ -197,7 +197,7 b' SystemExit Traceback (most recent call last)'
197 12
197 12
198 13 def bar(mode):
198 13 def bar(mode):
199 <BLANKLINE>
199 <BLANKLINE>
200 SystemExit: (2, 'Mode = exit')
200 SystemExit: (2, u'Mode = exit')
201
201
202 In [23]: %xmode verbose
202 In [23]: %xmode verbose
203 Exception reporting mode: Verbose
203 Exception reporting mode: Verbose
@@ -211,29 +211,29 b' SystemExit Traceback (most recent call last)'
211 31
211 31
212 ---> 32 bar(mode)
212 ---> 32 bar(mode)
213 global bar = <function bar at ...>
213 global bar = <function bar at ...>
214 global mode = 'exit'
214 global mode = u'exit'
215 <BLANKLINE>
215 <BLANKLINE>
216 ... in bar(mode='exit')
216 ... in bar(mode=u'exit')
217 20 except:
217 20 except:
218 21 stat = 1
218 21 stat = 1
219 ---> 22 sysexit(stat, mode)
219 ---> 22 sysexit(stat, mode)
220 global sysexit = <function sysexit at ...>
220 global sysexit = <function sysexit at ...>
221 stat = 2
221 stat = 2
222 mode = 'exit'
222 mode = u'exit'
223 23 else:
223 23 else:
224 24 raise ValueError('Unknown mode')
224 24 raise ValueError('Unknown mode')
225 <BLANKLINE>
225 <BLANKLINE>
226 ... in sysexit(stat=2, mode='exit')
226 ... in sysexit(stat=2, mode=u'exit')
227 9
227 9
228 10 def sysexit(stat, mode):
228 10 def sysexit(stat, mode):
229 ---> 11 raise SystemExit(stat, 'Mode = %s' % mode)
229 ---> 11 raise SystemExit(stat, 'Mode = %s' % mode)
230 global SystemExit = undefined
230 global SystemExit = undefined
231 stat = 2
231 stat = 2
232 mode = 'exit'
232 mode = u'exit'
233 12
233 12
234 13 def bar(mode):
234 13 def bar(mode):
235 <BLANKLINE>
235 <BLANKLINE>
236 SystemExit: (2, 'Mode = exit')
236 SystemExit: (2, u'Mode = exit')
237 """
237 """
238
238
239
239
@@ -179,8 +179,8 b' class TestMagicRunSimple(tt.TempFileMixin):'
179 "%%run '%s' C-second\n") % (tc, tc)
179 "%%run '%s' C-second\n") % (tc, tc)
180 self.mktmp(src, '.ipy')
180 self.mktmp(src, '.ipy')
181 out = """\
181 out = """\
182 ARGV 1-: ['C-first']
182 ARGV 1-: [u'C-first']
183 ARGV 1-: ['C-second']
183 ARGV 1-: [u'C-second']
184 tclass.py: deleting object: C-first
184 tclass.py: deleting object: C-first
185 """
185 """
186 tt.ipexec_validate(self.fname, out)
186 tt.ipexec_validate(self.fname, out)
General Comments 0
You need to be logged in to leave comments. Login now