2
2
3
3
from __future__ import unicode_literals
4
4
5
- import linecache
6
5
import sys
7
6
8
7
from curtsies .fmtfuncs import bold , green , magenta , cyan , red , plain
14
13
pypy = 'PyPy' in sys .version
15
14
16
15
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
-
23
16
class TestInterpreter (unittest .TestCase ):
24
17
def test_syntaxerror (self ):
25
18
i = interpreter .Interp ()
@@ -33,13 +26,13 @@ def append_to_a(message):
33
26
34
27
if pypy :
35
28
expected = (
36
- ' File ' + green ('"%s"' % _last_console_filename () ) +
29
+ ' File ' + green ('"<input>"' ) +
37
30
', line ' + bold (magenta ('1' )) + '\n 1.1.1.1\n ^\n ' +
38
31
bold (red ('SyntaxError' )) + ': ' + cyan ('invalid syntax' ) +
39
32
'\n ' )
40
33
else :
41
34
expected = (
42
- ' File ' + green ('"%s"' % _last_console_filename () ) +
35
+ ' File ' + green ('"<input>"' ) +
43
36
', line ' + bold (magenta ('1' )) + '\n 1.1.1.1\n ^\n ' +
44
37
bold (red ('SyntaxError' )) + ': ' + cyan ('invalid syntax' ) +
45
38
'\n ' )
@@ -62,7 +55,7 @@ def f():
62
55
def g ():
63
56
return f ()
64
57
65
- i .runsource ('g()' , encode = False )
58
+ i .runsource ('g()' )
66
59
67
60
if pypy :
68
61
global_not_found = "global name 'g' is not defined"
@@ -71,7 +64,7 @@ def g():
71
64
72
65
expected = (
73
66
'Traceback (most recent call last):\n File ' +
74
- green ('"%s"' % _last_console_filename () ) + ', line ' +
67
+ green ('"<input>"' ) + ', line ' +
75
68
bold (magenta ('1' )) + ', in ' + cyan ('<module>' ) + '\n g()\n ' +
76
69
bold (red ('NameError' )) + ': ' + cyan (global_not_found ) + '\n ' )
77
70
0 commit comments