[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/bpython/bpython/0.23-release/bpython/test/test_interpreter.py [Back]  [Original]

import sys
import re
import unittest

from curtsies.fmtfuncs import bold, green, magenta, cyan, red, plain
from unittest import mock

from bpython.curtsiesfrontend import interpreter

pypy = "PyPy" in sys.version


def remove_ansi(s):
    return re.sub(r"(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]".encode("ascii"), b"", s)


class TestInterpreter(unittest.TestCase):
    def interp_errlog(self):
        i = interpreter.Interp()
        a = []
        i.write = a.append
        return i, a

    def err_lineno(self, a):
        strings = [x.__unicode__() for x in a]
        for line in reversed(strings):
            clean_line = remove_ansi(line)
            m = re.search(r"line (\d+)[,]", clean_line)
            if m:
                return int(m.group(1))
        return None

    def test_syntaxerror(self):
        i, a = self.interp_errlog()

        i.runsource("1.1.1.1")

        if (3, 10, 1) 

Web Proxy Viewer  |  New URL  |  Original Page