Show More
@@ -29,9 +29,7 class TestAnsi(TestsBase): | |||||
29 |
|
29 | |||
30 |
|
30 | |||
31 | def test_strip_ansi(self): |
|
31 | def test_strip_ansi(self): | |
32 | """ |
|
32 | """strip_ansi test""" | |
33 | strip_ansi test |
|
|||
34 | """ |
|
|||
35 | correct_outputs = { |
|
33 | correct_outputs = { | |
36 | '%s%s%s' % (TermColors.Green, TermColors.White, TermColors.Red) : '', |
|
34 | '%s%s%s' % (TermColors.Green, TermColors.White, TermColors.Red) : '', | |
37 | 'hello%s' % TermColors.Blue: 'hello', |
|
35 | 'hello%s' % TermColors.Blue: 'hello', | |
@@ -50,9 +48,7 class TestAnsi(TestsBase): | |||||
50 |
|
48 | |||
51 |
|
49 | |||
52 | def test_ansi2html(self): |
|
50 | def test_ansi2html(self): | |
53 | """ |
|
51 | """ansi2html test""" | |
54 | ansi2html test |
|
|||
55 | """ |
|
|||
56 | correct_outputs = { |
|
52 | correct_outputs = { | |
57 | '%s' % (TermColors.Red) : '<span class="ansired"></span>', |
|
53 | '%s' % (TermColors.Red) : '<span class="ansired"></span>', | |
58 | 'hello%s' % TermColors.Blue: 'hello<span class="ansiblue"></span>', |
|
54 | 'hello%s' % TermColors.Blue: 'hello<span class="ansiblue"></span>', | |
@@ -71,9 +67,7 class TestAnsi(TestsBase): | |||||
71 |
|
67 | |||
72 |
|
68 | |||
73 | def test_ansi2latex(self): |
|
69 | def test_ansi2latex(self): | |
74 | """ |
|
70 | """ansi2latex test""" | |
75 | ansi2latex test |
|
|||
76 | """ |
|
|||
77 | correct_outputs = { |
|
71 | correct_outputs = { | |
78 | '%s' % (TermColors.Red) : r'\red{}', |
|
72 | '%s' % (TermColors.Red) : r'\red{}', | |
79 | 'hello%s' % TermColors.Blue: r'hello\blue{}', |
|
73 | 'hello%s' % TermColors.Blue: r'hello\blue{}', |
@@ -37,10 +37,10 class TestDataTypeFilter(TestsBase): | |||||
37 | filter = DataTypeFilter() |
|
37 | filter = DataTypeFilter() | |
38 | assert "png" in filter(["hair", "water", "png", "rock"]) |
|
38 | assert "png" in filter(["hair", "water", "png", "rock"]) | |
39 | assert "pdf" in filter(["pdf", "hair", "water", "png", "rock"]) |
|
39 | assert "pdf" in filter(["pdf", "hair", "water", "png", "rock"]) | |
40 |
assert |
|
40 | self.assert_equals(filter(["hair", "water", "rock"]), []) | |
41 |
|
41 | |||
42 |
|
42 | |||
43 | def test_null(self): |
|
43 | def test_null(self): | |
44 | """Will the DataTypeFilter fail if no types are passed in?""" |
|
44 | """Will the DataTypeFilter fail if no types are passed in?""" | |
45 | filter = DataTypeFilter() |
|
45 | filter = DataTypeFilter() | |
46 |
assert |
|
46 | self.assert_equals(filter([]), []) |
@@ -48,25 +48,19 class TestHighlight(TestsBase): | |||||
48 |
|
48 | |||
49 |
|
49 | |||
50 | def test_highlight2html(self): |
|
50 | def test_highlight2html(self): | |
51 | """ |
|
51 | """highlight2html test""" | |
52 | highlight2html test |
|
|||
53 | """ |
|
|||
54 | for index, test in enumerate(self.tests): |
|
52 | for index, test in enumerate(self.tests): | |
55 | yield self._try_highlight, highlight2html, test, self.tokens[index] |
|
53 | yield self._try_highlight, highlight2html, test, self.tokens[index] | |
56 |
|
54 | |||
57 |
|
55 | |||
58 | def test_highlight2latex(self): |
|
56 | def test_highlight2latex(self): | |
59 | """ |
|
57 | """highlight2latex test""" | |
60 | highlight2latex test |
|
|||
61 | """ |
|
|||
62 | for index, test in enumerate(self.tests): |
|
58 | for index, test in enumerate(self.tests): | |
63 | yield self._try_highlight, highlight2latex, test, self.tokens[index] |
|
59 | yield self._try_highlight, highlight2latex, test, self.tokens[index] | |
64 |
|
60 | |||
65 |
|
61 | |||
66 | def _try_highlight(self, method, test, tokens): |
|
62 | def _try_highlight(self, method, test, tokens): | |
67 | """ |
|
63 | """Try highlighting source, look for key tokens""" | |
68 | Try highlighting source, look for key tokens |
|
|||
69 | """ |
|
|||
70 | results = method(test) |
|
64 | results = method(test) | |
71 | for token in tokens: |
|
65 | for token in tokens: | |
72 | assert token in results |
|
66 | assert token in results |
@@ -27,9 +27,7 class TestLatex(TestsBase): | |||||
27 |
|
27 | |||
28 |
|
28 | |||
29 | def test_escape_latex(self): |
|
29 | def test_escape_latex(self): | |
30 | """ |
|
30 | """escape_latex test""" | |
31 | escape_latex test |
|
|||
32 | """ |
|
|||
33 | tests = [ |
|
31 | tests = [ | |
34 | (r'How are \you doing today?', r'How are \textbackslashyou doing today?'), |
|
32 | (r'How are \you doing today?', r'How are \textbackslashyou doing today?'), | |
35 | (r'\escapechar=`\A\catcode`\|=0 |string|foo', r'\textbackslashescapechar=`\textbackslashA\textbackslashcatcode`\textbackslash|=0 |string|foo'), |
|
33 | (r'\escapechar=`\A\catcode`\|=0 |string|foo', r'\textbackslashescapechar=`\textbackslashA\textbackslashcatcode`\textbackslash|=0 |string|foo'), | |
@@ -41,16 +39,12 class TestLatex(TestsBase): | |||||
41 |
|
39 | |||
42 |
|
40 | |||
43 | def _try_escape_latex(self, test, result): |
|
41 | def _try_escape_latex(self, test, result): | |
44 | """ |
|
42 | """Try to remove latex from string""" | |
45 | Try to remove latex from string |
|
|||
46 | """ |
|
|||
47 | self.assert_equal(escape_latex(test), result) |
|
43 | self.assert_equal(escape_latex(test), result) | |
48 |
|
44 | |||
49 |
|
45 | |||
50 | def test_strip_math_space(self): |
|
46 | def test_strip_math_space(self): | |
51 | """ |
|
47 | """strip_math_space test""" | |
52 | strip_math_space test |
|
|||
53 | """ |
|
|||
54 | tests = [ |
|
48 | tests = [ | |
55 | ('$e$','$e$'), |
|
49 | ('$e$','$e$'), | |
56 | ('$ e $','$e$'), |
|
50 | ('$ e $','$e$'), |
@@ -59,27 +59,21 class TestMarkdown(TestsBase): | |||||
59 |
|
59 | |||
60 | @onlyif_cmds_exist('pandoc') |
|
60 | @onlyif_cmds_exist('pandoc') | |
61 | def test_markdown2latex(self): |
|
61 | def test_markdown2latex(self): | |
62 | """ |
|
62 | """markdown2latex test""" | |
63 | markdown2latex test |
|
|||
64 | """ |
|
|||
65 | for index, test in enumerate(self.tests): |
|
63 | for index, test in enumerate(self.tests): | |
66 | yield self._try_markdown, markdown2latex, test, self.tokens[index] |
|
64 | yield self._try_markdown, markdown2latex, test, self.tokens[index] | |
67 |
|
65 | |||
68 |
|
66 | |||
69 | @onlyif_cmds_exist('pandoc') |
|
67 | @onlyif_cmds_exist('pandoc') | |
70 | def test_markdown2html(self): |
|
68 | def test_markdown2html(self): | |
71 | """ |
|
69 | """markdown2html test""" | |
72 | markdown2html test |
|
|||
73 | """ |
|
|||
74 | for index, test in enumerate(self.tests): |
|
70 | for index, test in enumerate(self.tests): | |
75 | yield self._try_markdown, markdown2html, test, self.tokens[index] |
|
71 | yield self._try_markdown, markdown2html, test, self.tokens[index] | |
76 |
|
72 | |||
77 |
|
73 | |||
78 | @onlyif_cmds_exist('pandoc') |
|
74 | @onlyif_cmds_exist('pandoc') | |
79 | def test_markdown2rst(self): |
|
75 | def test_markdown2rst(self): | |
80 | """ |
|
76 | """markdown2rst test""" | |
81 | markdown2rst test |
|
|||
82 | """ |
|
|||
83 |
|
77 | |||
84 | #Modify token array for rst, escape asterik |
|
78 | #Modify token array for rst, escape asterik | |
85 | tokens = copy(self.tokens) |
|
79 | tokens = copy(self.tokens) |
@@ -26,9 +26,7 from ..strings import (wrap_text, html2text, add_anchor, strip_dollars, | |||||
26 | class TestStrings(TestsBase): |
|
26 | class TestStrings(TestsBase): | |
27 |
|
27 | |||
28 | def test_wrap_text(self): |
|
28 | def test_wrap_text(self): | |
29 | """ |
|
29 | """wrap_text test""" | |
30 | wrap_text test |
|
|||
31 | """ |
|
|||
32 | test_text = """ |
|
30 | test_text = """ | |
33 | Tush! never tell me; I take it much unkindly |
|
31 | Tush! never tell me; I take it much unkindly | |
34 | That thou, Iago, who hast had my purse |
|
32 | That thou, Iago, who hast had my purse | |
@@ -42,17 +40,13 class TestStrings(TestsBase): | |||||
42 | assert len(line) <= length |
|
40 | assert len(line) <= length | |
43 |
|
41 | |||
44 | def test_html2text(self): |
|
42 | def test_html2text(self): | |
45 | """ |
|
43 | """html2text test""" | |
46 | html2text test |
|
|||
47 | """ |
|
|||
48 | #TODO: More tests |
|
44 | #TODO: More tests | |
49 | self.assert_equal(html2text('<name>joe</name>'), 'joe') |
|
45 | self.assert_equal(html2text('<name>joe</name>'), 'joe') | |
50 |
|
46 | |||
51 |
|
47 | |||
52 | def test_add_anchor(self): |
|
48 | def test_add_anchor(self): | |
53 | """ |
|
49 | """add_anchor test""" | |
54 | add_anchor test |
|
|||
55 | """ |
|
|||
56 | #TODO: More tests |
|
50 | #TODO: More tests | |
57 | results = add_anchor('<b>Hello World!</b>') |
|
51 | results = add_anchor('<b>Hello World!</b>') | |
58 | assert 'Hello World!' in results |
|
52 | assert 'Hello World!' in results | |
@@ -63,9 +57,7 class TestStrings(TestsBase): | |||||
63 |
|
57 | |||
64 |
|
58 | |||
65 | def test_strip_dollars(self): |
|
59 | def test_strip_dollars(self): | |
66 | """ |
|
60 | """strip_dollars test""" | |
67 | strip_dollars test |
|
|||
68 | """ |
|
|||
69 | tests = [ |
|
61 | tests = [ | |
70 | ('', ''), |
|
62 | ('', ''), | |
71 | ('$$', ''), |
|
63 | ('$$', ''), | |
@@ -84,9 +76,7 class TestStrings(TestsBase): | |||||
84 |
|
76 | |||
85 |
|
77 | |||
86 | def test_strip_files_prefix(self): |
|
78 | def test_strip_files_prefix(self): | |
87 | """ |
|
79 | """strip_files_prefix test""" | |
88 | strip_files_prefix test |
|
|||
89 | """ |
|
|||
90 | tests = [ |
|
80 | tests = [ | |
91 | ('', ''), |
|
81 | ('', ''), | |
92 | ('/files', '/files'), |
|
82 | ('/files', '/files'), | |
@@ -102,9 +92,7 class TestStrings(TestsBase): | |||||
102 |
|
92 | |||
103 |
|
93 | |||
104 | def test_comment_lines(self): |
|
94 | def test_comment_lines(self): | |
105 | """ |
|
95 | """comment_lines test""" | |
106 | comment_lines test |
|
|||
107 | """ |
|
|||
108 | for line in comment_lines('hello\nworld\n!').split('\n'): |
|
96 | for line in comment_lines('hello\nworld\n!').split('\n'): | |
109 | assert line.startswith('# ') |
|
97 | assert line.startswith('# ') | |
110 | for line in comment_lines('hello\nworld\n!', 'beep').split('\n'): |
|
98 | for line in comment_lines('hello\nworld\n!', 'beep').split('\n'): | |
@@ -112,9 +100,7 class TestStrings(TestsBase): | |||||
112 |
|
100 | |||
113 |
|
101 | |||
114 | def test_get_lines(self): |
|
102 | def test_get_lines(self): | |
115 | """ |
|
103 | """get_lines test""" | |
116 | get_lines test |
|
|||
117 | """ |
|
|||
118 | text = "hello\nworld\n!" |
|
104 | text = "hello\nworld\n!" | |
119 | self.assert_equal(get_lines(text, start=1), "world\n!") |
|
105 | self.assert_equal(get_lines(text, start=1), "world\n!") | |
120 | self.assert_equal(get_lines(text, end=2), "hello\nworld") |
|
106 | self.assert_equal(get_lines(text, end=2), "hello\nworld") | |
@@ -123,9 +109,7 class TestStrings(TestsBase): | |||||
123 |
|
109 | |||
124 |
|
110 | |||
125 | def test_ipython2python(self): |
|
111 | def test_ipython2python(self): | |
126 | """ |
|
112 | """ipython2python test""" | |
127 | ipython2python test |
|
|||
128 | """ |
|
|||
129 | #TODO: More tests |
|
113 | #TODO: More tests | |
130 | results = ipython2python(u'%%pylab\nprint("Hello-World")').replace("u'", "'") |
|
114 | results = ipython2python(u'%%pylab\nprint("Hello-World")').replace("u'", "'") | |
131 | self.fuzzy_compare(results, u"get_ipython().run_cell_magic('pylab', '', 'print(\"Hello-World\")')", |
|
115 | self.fuzzy_compare(results, u"get_ipython().run_cell_magic('pylab', '', 'print(\"Hello-World\")')", |
General Comments 0
You need to be logged in to leave comments.
Login now