Show More
@@ -1,76 +1,73 b'' | |||
|
1 | 1 | # coding: utf-8 |
|
2 | 2 | """Test suite for our color utilities. |
|
3 | 3 | |
|
4 | 4 | Authors |
|
5 | 5 | ------- |
|
6 | 6 | |
|
7 | 7 | * Min RK |
|
8 | 8 | """ |
|
9 | 9 | #----------------------------------------------------------------------------- |
|
10 | 10 | # Copyright (C) 2011 The IPython Development Team |
|
11 | 11 | # |
|
12 | 12 | # Distributed under the terms of the BSD License. The full license is in |
|
13 | 13 | # the file COPYING.txt, distributed as part of this software. |
|
14 | 14 | #----------------------------------------------------------------------------- |
|
15 | 15 | |
|
16 | 16 | #----------------------------------------------------------------------------- |
|
17 | 17 | # Imports |
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | # third party | |
|
21 | import nose.tools as nt | |
|
22 | ||
|
23 | 20 | from IPython.testing.decorators import skip_iptest_but_not_pytest |
|
24 | 21 | |
|
25 | 22 | # our own |
|
26 | 23 | from IPython.utils.PyColorize import Parser |
|
27 | 24 | import io |
|
28 | 25 | import pytest |
|
29 | 26 | |
|
30 | 27 | |
|
31 | 28 | @pytest.fixture(scope="module", params=("Linux", "NoColor", "LightBG", "Neutral")) |
|
32 | 29 | def style(request): |
|
33 | 30 | yield request.param |
|
34 | 31 | |
|
35 | 32 | #----------------------------------------------------------------------------- |
|
36 | 33 | # Test functions |
|
37 | 34 | #----------------------------------------------------------------------------- |
|
38 | 35 | |
|
39 | 36 | sample = """ |
|
40 | 37 | def function(arg, *args, kwarg=True, **kwargs): |
|
41 | 38 | ''' |
|
42 | 39 | this is docs |
|
43 | 40 | ''' |
|
44 | 41 | pass is True |
|
45 | 42 | False == None |
|
46 | 43 | |
|
47 | 44 | with io.open(ru'unicode'): |
|
48 | 45 | raise ValueError("\n escape \r sequence") |
|
49 | 46 | |
|
50 | 47 | print("wěird ünicoðe") |
|
51 | 48 | |
|
52 | 49 | class Bar(Super): |
|
53 | 50 | |
|
54 | 51 | def __init__(self): |
|
55 | 52 | super(Bar, self).__init__(1**2, 3^4, 5 or 6) |
|
56 | 53 | """ |
|
57 | 54 | |
|
58 | 55 | |
|
59 | 56 | @skip_iptest_but_not_pytest |
|
60 | 57 | def test_parse_sample(style): |
|
61 | 58 | """and test writing to a buffer""" |
|
62 | 59 | buf = io.StringIO() |
|
63 | 60 | p = Parser(style=style) |
|
64 | 61 | p.format(sample, buf) |
|
65 | 62 | buf.seek(0) |
|
66 | 63 | f1 = buf.read() |
|
67 | 64 | |
|
68 |
|
|
|
65 | assert "ERROR" not in f1 | |
|
69 | 66 | |
|
70 | 67 | |
|
71 | 68 | @skip_iptest_but_not_pytest |
|
72 | 69 | def test_parse_error(style): |
|
73 | 70 | p = Parser(style=style) |
|
74 | 71 | f1 = p.format(")", "str") |
|
75 | 72 | if style != "NoColor": |
|
76 |
|
|
|
73 | assert "ERROR" in f1 |
General Comments 0
You need to be logged in to leave comments.
Login now