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