Show More
@@ -1,92 +1,92 b'' | |||||
1 |
|
1 | |||
2 | """ |
|
2 | """ | |
3 | Module with tests for Markdown |
|
3 | Module with tests for Markdown | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
6 | #----------------------------------------------------------------------------- |
|
6 | #----------------------------------------------------------------------------- | |
7 | # Copyright (c) 2013, the IPython Development Team. |
|
7 | # Copyright (c) 2013, the IPython Development Team. | |
8 | # |
|
8 | # | |
9 | # Distributed under the terms of the Modified BSD License. |
|
9 | # Distributed under the terms of the Modified BSD License. | |
10 | # |
|
10 | # | |
11 | # The full license is in the file COPYING.txt, distributed with this software. |
|
11 | # The full license is in the file COPYING.txt, distributed with this software. | |
12 | #----------------------------------------------------------------------------- |
|
12 | #----------------------------------------------------------------------------- | |
13 |
|
13 | |||
14 | #----------------------------------------------------------------------------- |
|
14 | #----------------------------------------------------------------------------- | |
15 | # Imports |
|
15 | # Imports | |
16 | #----------------------------------------------------------------------------- |
|
16 | #----------------------------------------------------------------------------- | |
17 |
|
17 | |||
18 |
|
18 | |||
19 | from IPython.testing.decorators import onlyif_cmds_exist |
|
19 | from IPython.testing.decorators import onlyif_cmds_exist | |
20 | from IPython.utils.py3compat import string_types |
|
20 | from IPython.utils.py3compat import string_types | |
21 |
|
21 | |||
22 | from ...tests.base import TestsBase |
|
22 | from ...tests.base import TestsBase | |
23 | from ..markdown import * |
|
23 | from ..markdown import * | |
24 |
|
24 | |||
25 |
|
25 | |||
26 | #----------------------------------------------------------------------------- |
|
26 | #----------------------------------------------------------------------------- | |
27 | # Class |
|
27 | # Class | |
28 | #----------------------------------------------------------------------------- |
|
28 | #----------------------------------------------------------------------------- | |
29 |
|
29 | |||
30 | class TestMarkdown(TestsBase): |
|
30 | class TestMarkdown(TestsBase): | |
31 |
|
31 | |||
32 | tests = [ |
|
32 | tests = [ | |
33 | '*test', |
|
33 | '*test', | |
34 | '**test', |
|
34 | '**test', | |
35 | '*test*', |
|
35 | '*test*', | |
36 | '_test_', |
|
36 | '_test_', | |
37 | '__test__', |
|
37 | '__test__', | |
38 | '__*test*__', |
|
38 | '__*test*__', | |
39 | '**test**', |
|
39 | '**test**', | |
40 | '#test', |
|
40 | '#test', | |
41 | '##test', |
|
41 | '##test', | |
42 | 'test\n----', |
|
42 | 'test\n----', | |
43 | 'test [link](https://google.com/)'] |
|
43 | 'test [link](https://google.com/)'] | |
44 |
|
44 | |||
45 | tokens = [ |
|
45 | tokens = [ | |
46 | '*test', |
|
46 | '*test', | |
47 | '**test', |
|
47 | '**test', | |
48 | 'test', |
|
48 | 'test', | |
49 | 'test', |
|
49 | 'test', | |
50 | 'test', |
|
50 | 'test', | |
51 | 'test', |
|
51 | 'test', | |
52 | 'test', |
|
52 | 'test', | |
53 | 'test', |
|
53 | 'test', | |
54 | 'test', |
|
54 | 'test', | |
55 | 'test', |
|
55 | 'test', | |
56 | ('test', 'https://google.com/')] |
|
56 | ('test', 'https://google.com/')] | |
57 |
|
57 | |||
58 |
|
58 | |||
59 | @onlyif_cmds_exist('pandoc') |
|
59 | @onlyif_cmds_exist('pandoc') | |
60 | def test_markdown2latex(self): |
|
60 | def test_markdown2latex(self): | |
61 | """ |
|
61 | """ | |
62 | markdown2latex test |
|
62 | markdown2latex test | |
63 | """ |
|
63 | """ | |
64 | for index, test in enumerate(self.tests): |
|
64 | for index, test in enumerate(self.tests): | |
65 | yield self._try_markdown, markdown2latex, test, tokens[index] |
|
65 | yield self._try_markdown, markdown2latex, test, self.tokens[index] | |
66 |
|
66 | |||
67 |
|
67 | |||
68 | @onlyif_cmds_exist('pandoc') |
|
68 | @onlyif_cmds_exist('pandoc') | |
69 | def test_markdown2html(self): |
|
69 | def test_markdown2html(self): | |
70 | """ |
|
70 | """ | |
71 | markdown2html test |
|
71 | markdown2html test | |
72 | """ |
|
72 | """ | |
73 | for index, test in enumerate(self.tests): |
|
73 | for index, test in enumerate(self.tests): | |
74 | yield self._try_markdown, markdown2html, test, tokens[index] |
|
74 | yield self._try_markdown, markdown2html, test, self.tokens[index] | |
75 |
|
75 | |||
76 |
|
76 | |||
77 | @onlyif_cmds_exist('pandoc') |
|
77 | @onlyif_cmds_exist('pandoc') | |
78 | def test_markdown2rst(self): |
|
78 | def test_markdown2rst(self): | |
79 | """ |
|
79 | """ | |
80 | markdown2rst test |
|
80 | markdown2rst test | |
81 | """ |
|
81 | """ | |
82 | for index, test in enumerate(self.tests): |
|
82 | for index, test in enumerate(self.tests): | |
83 | yield self._try_markdown, markdown2rst, test, tokens[index] |
|
83 | yield self._try_markdown, markdown2rst, test, tokens[index] | |
84 |
|
84 | |||
85 |
|
85 | |||
86 | def _try_markdown(self, method, test, tokens): |
|
86 | def _try_markdown(self, method, test, tokens): | |
87 | results = method(test) |
|
87 | results = method(test) | |
88 | if isinstance(tokens, string_types): |
|
88 | if isinstance(tokens, string_types): | |
89 | assert tokens in results |
|
89 | assert tokens in results | |
90 | else: |
|
90 | else: | |
91 | for token in tokens: |
|
91 | for token in tokens: | |
92 | assert token in results |
|
92 | assert token in results |
General Comments 0
You need to be logged in to leave comments.
Login now