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