##// END OF EJS Templates
Statically type OInfo. (#13973)...
Statically type OInfo. (#13973) In view of working with #13860, some cleanup inspect to be properly typed, and using stricter datastructure. Instead of dict we now use dataclasses, this will make sure that fields type and access can be stricter and verified not only at runtime, but by mypy

File last commit:

r27494:23276ac4
r28166:29b451fc merge
Show More
test_pycolorize.py
69 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
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("\n 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(")", "str")
if style != "NoColor":
assert "ERROR" in f1