##// END OF EJS Templates
bugfix for call to structured_traceback (#14453)...
bugfix for call to structured_traceback (#14453) Calls to `structured_traceback` take the exploded 3-tuple of `*sys.exc_info()` as separate arguments, so we don't want to pass the 3-tuple as one argument. This should fix some of the symptoms people are seeing in https://github.com/ipython/ipython/issues/12831 Test plan: local editable install, seems to work OK. Haven't tried to repro the problem from the linked issue but this change probably can't hurt. From https://github.com/ipython/ipython/pull/14454, which is just an empty commit, I see the same test failures as in this PR's "Run Downstream tests" job: https://github.com/ipython/ipython/actions/runs/9375565881/job/25813901627?pr=14454 So I'm guessing it's not related to the change in this PR.

File last commit:

r28326:1098b2c1
r28790:1454013b merge
Show More
test_pycolorize.py
70 lines | 1.7 KiB | text/x-python | PythonLexer
# coding: utf-8
"""Test suite for our color utilities.
Authors
-------
* Min RK
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2011 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING.txt, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
# our own
import sys
from IPython.utils.PyColorize import Parser
import io
import pytest
@pytest.fixture(scope="module", params=("Linux", "NoColor", "LightBG", "Neutral"))
def style(request):
yield request.param
#-----------------------------------------------------------------------------
# Test functions
#-----------------------------------------------------------------------------
sample = """
def function(arg, *args, kwarg=True, **kwargs):
'''
this is docs
'''
pass is True
False == None
with io.open(ru'unicode', encoding='utf-8'):
raise ValueError("escape \r sequence")
print("wěird ünicoðe")
class Bar(Super):
def __init__(self):
super(Bar, self).__init__(1**2, 3^4, 5 or 6)
"""
def test_parse_sample(style):
"""and test writing to a buffer"""
buf = io.StringIO()
p = Parser(style=style)
p.format(sample, buf)
buf.seek(0)
f1 = buf.read()
assert "ERROR" not in f1
def test_parse_error(style):
p = Parser(style=style)
f1 = p.format(r"\ " if sys.version_info >= (3, 12) else ")", "str")
if style != "NoColor":
assert "ERROR" in f1