Show More
@@ -17,7 +17,7 b' Module with tests for Markdown' | |||||
17 |
|
17 | |||
18 |
|
18 | |||
19 | from IPython.testing.decorators import onlyif_cmds_exist |
|
19 | from IPython.testing.decorators import onlyif_cmds_exist | |
20 | # @onlyif_cmds_exist('pandoc') |
|
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 * | |
@@ -42,30 +42,27 b' class TestMarkdown(TestsBase):' | |||||
42 | 'test\n----', |
|
42 | 'test\n----', | |
43 | 'test [link](https://google.com/)'] |
|
43 | 'test [link](https://google.com/)'] | |
44 |
|
44 | |||
|
45 | tokens = [ | |||
|
46 | '*test', | |||
|
47 | '**test', | |||
|
48 | 'test', | |||
|
49 | 'test', | |||
|
50 | 'test', | |||
|
51 | 'test', | |||
|
52 | 'test', | |||
|
53 | 'test', | |||
|
54 | 'test', | |||
|
55 | 'test', | |||
|
56 | ('test', 'https://google.com/')] | |||
|
57 | ||||
45 |
|
58 | |||
46 | @onlyif_cmds_exist('pandoc') |
|
59 | @onlyif_cmds_exist('pandoc') | |
47 | def test_markdown2latex(self): |
|
60 | def test_markdown2latex(self): | |
48 | """ |
|
61 | """ | |
49 | markdown2latex test |
|
62 | markdown2latex test | |
50 | """ |
|
63 | """ | |
51 | results = [ |
|
|||
52 | '*test', |
|
|||
53 | '**test', |
|
|||
54 | r'\emph{test}', |
|
|||
55 | r'\emph{test}', |
|
|||
56 | r'\textbf{test}', |
|
|||
57 | r'\textbf{\emph{test}}', |
|
|||
58 | r'\textbf{test}', |
|
|||
59 | r'\section{test}', |
|
|||
60 | r'\subsection{test}', |
|
|||
61 | r'\subsection{test}', |
|
|||
62 | r'test \href{https://google.com/}{link}'] |
|
|||
63 | for index, test in enumerate(self.tests): |
|
64 | for index, test in enumerate(self.tests): | |
64 |
yield self._try_markdown2latex, test, |
|
65 | yield self._try_markdown, markdown2latex, test, tokens[index] | |
65 |
|
||||
66 |
|
||||
67 | def _try_markdown2latex(self, test, results): |
|
|||
68 | self.fuzzy_compare(markdown2latex(test), results) |
|
|||
69 |
|
66 | |||
70 |
|
67 | |||
71 | @onlyif_cmds_exist('pandoc') |
|
68 | @onlyif_cmds_exist('pandoc') | |
@@ -73,24 +70,8 b' class TestMarkdown(TestsBase):' | |||||
73 | """ |
|
70 | """ | |
74 | markdown2html test |
|
71 | markdown2html test | |
75 | """ |
|
72 | """ | |
76 | results = [ |
|
|||
77 | '<p>*test</p>', |
|
|||
78 | '<p>**test</p>', |
|
|||
79 | '<p><em>test</em></p>', |
|
|||
80 | '<p><em>test</em></p>', |
|
|||
81 | '<p><strong>test</strong></p>', |
|
|||
82 | '<p><strong><em>test</em></strong></p>', |
|
|||
83 | '<p><strong>test</strong></p>', |
|
|||
84 | '<h1 id="test">test</h1>', |
|
|||
85 | '<h2 id="test">test</h2>', |
|
|||
86 | '<h2 id="test">test</h2>', |
|
|||
87 | '<p>test <a href="https://google.com/">link</a></p>'] |
|
|||
88 | for index, test in enumerate(self.tests): |
|
73 | for index, test in enumerate(self.tests): | |
89 |
yield self._try_markdown2html, test, |
|
74 | yield self._try_markdown, markdown2html, test, tokens[index] | |
90 |
|
||||
91 |
|
||||
92 | def _try_markdown2html(self, test, results): |
|
|||
93 | self.fuzzy_compare(markdown2html(test), results) |
|
|||
94 |
|
75 | |||
95 |
|
76 | |||
96 | @onlyif_cmds_exist('pandoc') |
|
77 | @onlyif_cmds_exist('pandoc') | |
@@ -98,21 +79,14 b' class TestMarkdown(TestsBase):' | |||||
98 | """ |
|
79 | """ | |
99 | markdown2rst test |
|
80 | markdown2rst test | |
100 | """ |
|
81 | """ | |
101 | results = [ |
|
|||
102 | '\*test', |
|
|||
103 | '\*\*test', |
|
|||
104 | '*test*', |
|
|||
105 | '*test*', |
|
|||
106 | '**test**', |
|
|||
107 | '***test***', |
|
|||
108 | '**test**', |
|
|||
109 | 'test\n====', |
|
|||
110 | 'test\n----', |
|
|||
111 | 'test\n----', |
|
|||
112 | 'test `link <https://google.com/>`_'] |
|
|||
113 | for index, test in enumerate(self.tests): |
|
82 | for index, test in enumerate(self.tests): | |
114 |
yield self._try_markdown2rst, test, |
|
83 | yield self._try_markdown, markdown2rst, test, tokens[index] | |
115 |
|
84 | |||
116 |
|
85 | |||
117 |
def _try_markdown |
|
86 | def _try_markdown(self, method, test, tokens): | |
118 | self.fuzzy_compare(markdown2rst(test), results) |
|
87 | results = method(test) | |
|
88 | if isinstance(tokens, string_types): | |||
|
89 | assert tokens in results | |||
|
90 | else: | |||
|
91 | for token in tokens: | |||
|
92 | assert token in results |
General Comments 0
You need to be logged in to leave comments.
Login now