Skip to content

Commit b38f6c7

Browse files
committed
Remove unused code
1 parent 406f871 commit b38f6c7

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

bpython/test/test_interpreter.py

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
11
import sys
2-
import re
32
import unittest
43

54
from curtsies.fmtfuncs import bold, green, magenta, cyan, red, plain
6-
from unittest import mock
75

86
from bpython.curtsiesfrontend import interpreter
97

108
pypy = "PyPy" in sys.version
119

1210

13-
def remove_ansi(s):
14-
return re.sub(r"(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]".encode("ascii"), b"", s)
11+
class Interpreter(interpreter.Interp):
12+
def __init__(self):
13+
super().__init__()
14+
self.a = []
1515

16+
def write(self, data):
17+
self.a.append(data)
1618

17-
class TestInterpreter(unittest.TestCase):
18-
def interp_errlog(self):
19-
i = interpreter.Interp()
20-
a = []
21-
i.write = a.append
22-
return i, a
23-
24-
def err_lineno(self, a):
25-
strings = [x.__unicode__() for x in a]
26-
for line in reversed(strings):
27-
clean_line = remove_ansi(line)
28-
m = re.search(r"line (\d+)[,]", clean_line)
29-
if m:
30-
return int(m.group(1))
31-
return None
3219

20+
class TestInterpreter(unittest.TestCase):
3321
def test_syntaxerror(self):
34-
i, a = self.interp_errlog()
22+
i = Interpreter()
3523

3624
i.runsource("1.1.1.1")
3725

@@ -96,11 +84,12 @@ def test_syntaxerror(self):
9684
+ "\n"
9785
)
9886

87+
a = i.a
9988
self.assertMultiLineEqual(str(plain("").join(a)), str(expected))
10089
self.assertEqual(plain("").join(a), expected)
10190

10291
def test_traceback(self):
103-
i, a = self.interp_errlog()
92+
i = Interpreter()
10493

10594
def f():
10695
return 1 / 0
@@ -142,6 +131,7 @@ def gfunc():
142131
+ "\n"
143132
)
144133

134+
a = i.a
145135
self.assertMultiLineEqual(str(plain("").join(a)), str(expected))
146136
self.assertEqual(plain("").join(a), expected)
147137

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy