22
33from __future__ import unicode_literals
44
5- import linecache
65import sys
76
87from curtsies .fmtfuncs import bold , green , magenta , cyan , red , plain
1413pypy = 'PyPy' in sys .version
1514
1615
17- def _last_console_filename ():
18- """Returns the last 'filename' used for console input
19- (as will be displayed in a traceback)."""
20- return '<bpython-input-%s>' % (len (linecache .cache .bpython_history ) - 1 )
21-
22-
2316class TestInterpreter (unittest .TestCase ):
2417 def test_syntaxerror (self ):
2518 i = interpreter .Interp ()
@@ -33,13 +26,13 @@ def append_to_a(message):
3326
3427 if pypy :
3528 expected = (
36- ' File ' + green ('"%s"' % _last_console_filename () ) +
29+ ' File ' + green ('"<input>"' ) +
3730 ', line ' + bold (magenta ('1' )) + '\n 1.1.1.1\n ^\n ' +
3831 bold (red ('SyntaxError' )) + ': ' + cyan ('invalid syntax' ) +
3932 '\n ' )
4033 else :
4134 expected = (
42- ' File ' + green ('"%s"' % _last_console_filename () ) +
35+ ' File ' + green ('"<input>"' ) +
4336 ', line ' + bold (magenta ('1' )) + '\n 1.1.1.1\n ^\n ' +
4437 bold (red ('SyntaxError' )) + ': ' + cyan ('invalid syntax' ) +
4538 '\n ' )
@@ -62,7 +55,7 @@ def f():
6255 def g ():
6356 return f ()
6457
65- i .runsource ('g()' , encode = False )
58+ i .runsource ('g()' )
6659
6760 if pypy :
6861 global_not_found = "global name 'g' is not defined"
@@ -71,7 +64,7 @@ def g():
7164
7265 expected = (
7366 'Traceback (most recent call last):\n File ' +
74- green ('"%s"' % _last_console_filename () ) + ', line ' +
67+ green ('"<input>"' ) + ', line ' +
7568 bold (magenta ('1' )) + ', in ' + cyan ('<module>' ) + '\n g()\n ' +
7669 bold (red ('NameError' )) + ': ' + cyan (global_not_found ) + '\n ' )
7770
0 commit comments