##// END OF EJS Templates
Use decorator to enable test generation
Jonathan Frederic -
Show More
@@ -14,6 +14,7 b' Module with tests for ansi filters'
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
17 18 from IPython.utils.coloransi import TermColors
18 19
19 20 from ...tests.base import TestsBase
@@ -27,7 +28,7 b' from ..ansi import strip_ansi, ansi2html, ansi2latex'
27 28 class TestAnsi(TestsBase):
28 29 """Contains test functions for ansi.py"""
29 30
30
31 @dec.parametric
31 32 def test_strip_ansi(self):
32 33 """strip_ansi test"""
33 34 correct_outputs = {
@@ -47,6 +48,7 b' class TestAnsi(TestsBase):'
47 48 self.assert_equal(outval, strip_ansi(inval))
48 49
49 50
51 @dec.parametric
50 52 def test_ansi2html(self):
51 53 """ansi2html test"""
52 54 correct_outputs = {
@@ -66,6 +68,7 b' class TestAnsi(TestsBase):'
66 68 self.fuzzy_compare(outval, ansi2html(inval))
67 69
68 70
71 @dec.parametric
69 72 def test_ansi2latex(self):
70 73 """ansi2latex test"""
71 74 correct_outputs = {
@@ -14,6 +14,7 b' Module with tests for Highlight'
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
17 18
18 19 from ...tests.base import TestsBase
19 20 from ..highlight import highlight2html, highlight2latex
@@ -47,12 +48,14 b' class TestHighlight(TestsBase):'
47 48 ['pylab', 'plot']]
48 49
49 50
51 @dec.parametric
50 52 def test_highlight2html(self):
51 53 """highlight2html test"""
52 54 for index, test in enumerate(self.tests):
53 55 yield self._try_highlight, highlight2html, test, self.tokens[index]
54 56
55 57
58 @dec.parametric
56 59 def test_highlight2latex(self):
57 60 """highlight2latex test"""
58 61 for index, test in enumerate(self.tests):
@@ -14,6 +14,7 b' Module with tests for Latex'
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
17 18
18 19 from ...tests.base import TestsBase
19 20 from ..latex import escape_latex, strip_math_space
@@ -26,6 +27,7 b' from ..latex import escape_latex, strip_math_space'
26 27 class TestLatex(TestsBase):
27 28
28 29
30 @dec.parametric
29 31 def test_escape_latex(self):
30 32 """escape_latex test"""
31 33 tests = [
@@ -43,6 +45,7 b' class TestLatex(TestsBase):'
43 45 self.assert_equal(escape_latex(test), result)
44 46
45 47
48 @dec.parametric
46 49 def test_strip_math_space(self):
47 50 """strip_math_space test"""
48 51 tests = [
@@ -17,8 +17,8 b' Module with tests for Markdown'
17 17
18 18 from copy import copy
19 19
20 from IPython.testing.decorators import onlyif_cmds_exist
21 20 from IPython.utils.py3compat import string_types
21 from IPython.testing import decorators as dec
22 22
23 23 from ...tests.base import TestsBase
24 24 from ..markdown import markdown2latex, markdown2html, markdown2rst
@@ -57,21 +57,24 b' class TestMarkdown(TestsBase):'
57 57 ('test', 'https://google.com/')]
58 58
59 59
60 @onlyif_cmds_exist('pandoc')
60 @dec.onlyif_cmds_exist('pandoc')
61 @dec.parametric
61 62 def test_markdown2latex(self):
62 63 """markdown2latex test"""
63 64 for index, test in enumerate(self.tests):
64 65 yield self._try_markdown, markdown2latex, test, self.tokens[index]
65 66
66 67
67 @onlyif_cmds_exist('pandoc')
68 @dec.onlyif_cmds_exist('pandoc')
69 @dec.parametric
68 70 def test_markdown2html(self):
69 71 """markdown2html test"""
70 72 for index, test in enumerate(self.tests):
71 73 yield self._try_markdown, markdown2html, test, self.tokens[index]
72 74
73 75
74 @onlyif_cmds_exist('pandoc')
76 @dec.onlyif_cmds_exist('pandoc')
77 @dec.parametric
75 78 def test_markdown2rst(self):
76 79 """markdown2rst test"""
77 80
@@ -14,6 +14,7 b' Module with tests for Strings'
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 from IPython.testing import decorators as dec
17 18 from ...tests.base import TestsBase
18 19 from ..strings import (wrap_text, html2text, add_anchor, strip_dollars,
19 20 strip_files_prefix, get_lines, comment_lines, ipython2python)
@@ -25,6 +26,7 b' from ..strings import (wrap_text, html2text, add_anchor, strip_dollars,'
25 26
26 27 class TestStrings(TestsBase):
27 28
29 @dec.parametric
28 30 def test_wrap_text(self):
29 31 """wrap_text test"""
30 32 test_text = """
@@ -35,10 +37,12 b' class TestStrings(TestsBase):'
35 37 for length in [30,5,1]:
36 38 yield self._confirm_wrap_text, test_text, length
37 39
40
38 41 def _confirm_wrap_text(self, text, length):
39 42 for line in wrap_text(text, length).split('\n'):
40 43 assert len(line) <= length
41 44
45
42 46 def test_html2text(self):
43 47 """html2text test"""
44 48 #TODO: More tests
@@ -56,6 +60,7 b' class TestStrings(TestsBase):'
56 60 assert '</b>' in results
57 61
58 62
63 @dec.parametric
59 64 def test_strip_dollars(self):
60 65 """strip_dollars test"""
61 66 tests = [
@@ -75,6 +80,7 b' class TestStrings(TestsBase):'
75 80 self.assert_equal(strip_dollars(test), result)
76 81
77 82
83 @dec.parametric
78 84 def test_strip_files_prefix(self):
79 85 """strip_files_prefix test"""
80 86 tests = [
General Comments 0
You need to be logged in to leave comments. Login now