##// END OF EJS Templates
[core][tests][interactiveshell] Remove nose
[core][tests][interactiveshell] Remove nose

File last commit:

r26183:61376395
r26901:85ad41c0
Show More
test_pycolorize.py
76 lines | 1.8 KiB | text/x-python | PythonLexer
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801 # coding: utf-8
MinRK
always use StringIO, never cStringIO...
r4794 """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
#-----------------------------------------------------------------------------
# third party
import nose.tools as nt
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 from IPython.testing.decorators import skip_iptest_but_not_pytest
MinRK
always use StringIO, never cStringIO...
r4794 # our own
from IPython.utils.PyColorize import Parser
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801 import io
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 import pytest
@pytest.fixture(scope="module", params=("Linux", "NoColor", "LightBG", "Neutral"))
def style(request):
yield request.param
MinRK
always use StringIO, never cStringIO...
r4794
#-----------------------------------------------------------------------------
# Test functions
#-----------------------------------------------------------------------------
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 sample = """
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801 def function(arg, *args, kwarg=True, **kwargs):
'''
this is docs
'''
pass is True
False == None
MinRK
always use StringIO, never cStringIO...
r4794
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801 with io.open(ru'unicode'):
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)
"""
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 @skip_iptest_but_not_pytest
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()
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 nt.assert_not_in("ERROR", f1)
Matthias Bussonnier
Test more edge cases of the highlighting parser
r21801
Matthias Bussonnier
Remove yield test that are not support by pytest anymore...
r26183 @skip_iptest_but_not_pytest
def test_parse_error(style):
p = Parser(style=style)
f1 = p.format(")", "str")
if style != "NoColor":
nt.assert_in("ERROR", f1)