##// END OF EJS Templates
s/Test_/Test
Jonathan Frederic -
Show More
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for basichtml.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..basichtml import BasicHTMLExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_BasicHTMLExporter(ExportersTestsBase):
24 class TestBasicHTMLExporter(ExportersTestsBase):
25 25 """Contains test functions for basichtml.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a BasicHTMLExporter be constructed?
30 30 """
31 31 BasicHTMLExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a BasicHTMLExporter export something?
37 37 """
38 38 (output, resources) = BasicHTMLExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,102 +1,102 b''
1 1 """
2 2 Module with tests for export.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 import os
18 18
19 19 from IPython.nbformat import current as nbformat
20 20
21 21 from .base import ExportersTestsBase
22 22 from ..export import *
23 23 from ..python import PythonExporter
24 24
25 25 #-----------------------------------------------------------------------------
26 26 # Class
27 27 #-----------------------------------------------------------------------------
28 28
29 class Test_Export(ExportersTestsBase):
29 class TestExport(ExportersTestsBase):
30 30 """Contains test functions for export.py"""
31 31
32 32
33 33 def test_export_wrong_name(self):
34 34 """
35 35 Is the right error thrown when a bad template name is used?
36 36 """
37 37 try:
38 38 export_by_name('not_a_name', self._get_notebook())
39 39 except ExporterNameError as e:
40 40 pass
41 41
42 42
43 43 def test_export_filename(self):
44 44 """
45 45 Can a notebook be exported by filename?
46 46 """
47 47 (output, resources) = export_by_name('python', self._get_notebook())
48 48 assert len(output) > 0
49 49
50 50
51 51 def test_export_nbnode(self):
52 52 """
53 53 Can a notebook be exported by a notebook node handle?
54 54 """
55 55 with open(self._get_notebook(), 'r') as f:
56 56 notebook = nbformat.read(f, 'json')
57 57 (output, resources) = export_by_name('python', notebook)
58 58 assert len(output) > 0
59 59
60 60
61 61 def test_export_filestream(self):
62 62 """
63 63 Can a notebook be exported by a filesteam?
64 64 """
65 65 with open(self._get_notebook(), 'r') as f:
66 66 (output, resources) = export_by_name('python', f)
67 67 assert len(output) > 0
68 68
69 69
70 70 def test_export_using_exporter(self):
71 71 """
72 72 Can a notebook be exported using an instanciated exporter?
73 73 """
74 74 (output, resources) = export(PythonExporter(), self._get_notebook())
75 75 assert len(output) > 0
76 76
77 77
78 78 def test_export_using_exporter_class(self):
79 79 """
80 80 Can a notebook be exported using an exporter class type?
81 81 """
82 82 (output, resources) = export(PythonExporter, self._get_notebook())
83 83 assert len(output) > 0
84 84
85 85
86 86 def test_export_resources(self):
87 87 """
88 88 Can a notebook be exported along with a custom resources dict?
89 89 """
90 90 (output, resources) = export(PythonExporter, self._get_notebook(), resources={})
91 91 assert len(output) > 0
92 92
93 93
94 94 def test_no_exporter(self):
95 95 """
96 96 Is the right error thrown if no exporter is provided?
97 97 """
98 98 try:
99 99 (output, resources) = export(None, self._get_notebook())
100 100 except TypeError:
101 101 pass
102 102 No newline at end of file
@@ -1,113 +1,113 b''
1 1 """
2 2 Module with tests for exporter.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from IPython.config import Config
18 18
19 19 from .base import ExportersTestsBase
20 20 from .cheese import CheeseTransformer
21 21 from ..exporter import Exporter
22 22
23 23
24 24 #-----------------------------------------------------------------------------
25 25 # Class
26 26 #-----------------------------------------------------------------------------
27 27
28 class Test_Exporter(ExportersTestsBase):
28 class TestExporter(ExportersTestsBase):
29 29 """Contains test functions for exporter.py"""
30 30
31 31
32 32 def test_constructor(self):
33 33 """
34 34 Can an Exporter be constructed?
35 35 """
36 36 Exporter()
37 37
38 38
39 39 def test_export(self):
40 40 """
41 41 Can an Exporter export something?
42 42 """
43 43 exporter = self._make_exporter()
44 44 (output, resources) = exporter.from_filename(self._get_notebook())
45 45 assert len(output) > 0
46 46
47 47
48 48 def test_extract_figures(self):
49 49 """
50 50 If the ExtractFigureTransformer is enabled, are figures extracted?
51 51 """
52 52 config = Config({'ExtractFigureTransformer': {'enabled': True}})
53 53 exporter = self._make_exporter(config=config)
54 54 (output, resources) = exporter.from_filename(self._get_notebook())
55 55 assert resources is not None
56 56 assert 'figures' in resources
57 57 assert len(resources['figures']) > 0
58 58
59 59
60 60 def test_transformer_class(self):
61 61 """
62 62 Can a transformer be added to the transformers list by class type?
63 63 """
64 64 config = Config({'Exporter': {'transformers': [CheeseTransformer]}})
65 65 exporter = self._make_exporter(config=config)
66 66 (output, resources) = exporter.from_filename(self._get_notebook())
67 67 assert resources is not None
68 68 assert 'cheese' in resources
69 69 assert resources['cheese'] == 'real'
70 70
71 71
72 72 def test_transformer_instance(self):
73 73 """
74 74 Can a transformer be added to the transformers list by instance?
75 75 """
76 76 config = Config({'Exporter': {'transformers': [CheeseTransformer()]}})
77 77 exporter = self._make_exporter(config=config)
78 78 (output, resources) = exporter.from_filename(self._get_notebook())
79 79 assert resources is not None
80 80 assert 'cheese' in resources
81 81 assert resources['cheese'] == 'real'
82 82
83 83
84 84 def test_transformer_dottedobjectname(self):
85 85 """
86 86 Can a transformer be added to the transformers list by dotted object name?
87 87 """
88 88 config = Config({'Exporter': {'transformers': ['IPython.nbconvert.exporters.tests.cheese.CheeseTransformer']}})
89 89 exporter = self._make_exporter(config=config)
90 90 (output, resources) = exporter.from_filename(self._get_notebook())
91 91 assert resources is not None
92 92 assert 'cheese' in resources
93 93 assert resources['cheese'] == 'real'
94 94
95 95
96 96 def test_transformer_via_method(self):
97 97 """
98 98 Can a transformer be added via the Exporter convinience method?
99 99 """
100 100 exporter = self._make_exporter()
101 101 exporter.register_transformer(CheeseTransformer, enabled=True)
102 102 (output, resources) = exporter.from_filename(self._get_notebook())
103 103 assert resources is not None
104 104 assert 'cheese' in resources
105 105 assert resources['cheese'] == 'real'
106 106
107 107
108 108 def _make_exporter(self, config=None):
109 109 #Create the exporter instance, make sure to set a template name since
110 110 #the base Exporter doesn't have a template associated with it.
111 111 exporter = Exporter(config=config)
112 112 exporter.template_file = 'python'
113 113 return exporter No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for fullhtml.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..fullhtml import FullHTMLExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_FullHTMLExporter(ExportersTestsBase):
24 class TestFullHTMLExporter(ExportersTestsBase):
25 25 """Contains test functions for fullhtml.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a FullHTMLExporter be constructed?
30 30 """
31 31 FullHTMLExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a FullHTMLExporter export something?
37 37 """
38 38 (output, resources) = FullHTMLExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for latex.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..latex import LatexExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_LatexExporter(ExportersTestsBase):
24 class TestLatexExporter(ExportersTestsBase):
25 25 """Contains test functions for latex.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a LatexExporter be constructed?
30 30 """
31 31 LatexExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a LatexExporter export something?
37 37 """
38 38 (output, resources) = LatexExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for markdown.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..markdown import MarkdownExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_MarkdownExporter(ExportersTestsBase):
24 class TestMarkdownExporter(ExportersTestsBase):
25 25 """Contains test functions for markdown.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a MarkdownExporter be constructed?
30 30 """
31 31 MarkdownExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a MarkdownExporter export something?
37 37 """
38 38 (output, resources) = MarkdownExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for python.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..python import PythonExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_PythonExporter(ExportersTestsBase):
24 class TestPythonExporter(ExportersTestsBase):
25 25 """Contains test functions for python.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a PythonExporter be constructed?
30 30 """
31 31 PythonExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a PythonExporter export something?
37 37 """
38 38 (output, resources) = PythonExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for reveal.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..reveal import RevealExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_RevealExporter(ExportersTestsBase):
24 class TestRevealExporter(ExportersTestsBase):
25 25 """Contains test functions for reveal.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a RevealExporter be constructed?
30 30 """
31 31 RevealExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a RevealExporter export something?
37 37 """
38 38 (output, resources) = RevealExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for rst.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..rst import RSTExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_RstExporter(ExportersTestsBase):
24 class TestRSTExporter(ExportersTestsBase):
25 25 """Contains test functions for rst.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a RSTExporter be constructed?
30 30 """
31 31 RSTExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a RSTExporter export something?
37 37 """
38 38 (output, resources) = RSTExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for sphinx_howto.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..sphinx_howto import SphinxHowtoExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_SphinxHowtoExporter(ExportersTestsBase):
24 class TestSphinxHowtoExporter(ExportersTestsBase):
25 25 """Contains test functions for sphinx_howto.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a SphinxHowtoExporter be constructed?
30 30 """
31 31 SphinxHowtoExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a SphinxHowtoExporter export something?
37 37 """
38 38 (output, resources) = SphinxHowtoExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,39 +1,39 b''
1 1 """
2 2 Module with tests for sphinx_manual.py
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from .base import ExportersTestsBase
18 18 from ..sphinx_manual import SphinxManualExporter
19 19
20 20 #-----------------------------------------------------------------------------
21 21 # Class
22 22 #-----------------------------------------------------------------------------
23 23
24 class Test_SphinxManualExporter(ExportersTestsBase):
24 class TestSphinxManualExporter(ExportersTestsBase):
25 25 """Contains test functions for sphinx_manual.py"""
26 26
27 27 def test_constructor(self):
28 28 """
29 29 Can a SphinxManualExporter be constructed?
30 30 """
31 31 SphinxManualExporter()
32 32
33 33
34 34 def test_export(self):
35 35 """
36 36 Can a SphinxManualExporter export something?
37 37 """
38 38 (output, resources) = SphinxManualExporter().from_filename(self._get_notebook())
39 39 assert len(output) > 0 No newline at end of file
@@ -1,91 +1,91 b''
1 1 """
2 2 Module with tests for ansi filters
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17 from IPython.utils.coloransi import TermColors
18 18
19 19 from ...tests.base import TestsBase
20 20 from ..ansi import *
21 21
22 22
23 23 #-----------------------------------------------------------------------------
24 24 # Class
25 25 #-----------------------------------------------------------------------------
26 26
27 class Test_Ansi(TestsBase):
27 class TestAnsi(TestsBase):
28 28 """Contains test functions for ansi.py"""
29 29
30 30
31 31 def test_remove_ansi(self):
32 32 """
33 33 remove_ansi test
34 34 """
35 35 correct_outputs = {
36 36 '%s%s%s' % (TermColors.Green, TermColors.White, TermColors.Red) : '',
37 37 'hello%s' % TermColors.Blue: 'hello',
38 38 'he%s%sllo' % (TermColors.Yellow, TermColors.Cyan) : 'hello',
39 39 '%shello' % TermColors.Blue : 'hello',
40 40 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.Red) : 'hello',
41 41 'hel%slo' % TermColors.Green : 'hello',
42 42 'hello' : 'hello'}
43 43
44 44 for inval, outval in correct_outputs.items():
45 45 yield self._try_remove_ansi, inval, outval
46 46
47 47
48 48 def _try_remove_ansi(self, inval, outval):
49 49 assert outval == remove_ansi(inval)
50 50
51 51
52 52 def test_ansi2html(self):
53 53 """
54 54 ansi2html test
55 55 """
56 56 correct_outputs = {
57 57 '%s' % (TermColors.Red) : '<span class="ansired"></span>',
58 58 'hello%s' % TermColors.Blue: 'hello<span class="ansiblue"></span>',
59 59 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : 'he<span class="ansigreen"></span><span class="ansicyan">llo</span>',
60 60 '%shello' % TermColors.Yellow : '<span class="ansiyellow">hello</span>',
61 61 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : '<span class="ansigrey">h</span><span class="ansigrey">e</span><span class="ansigrey">l</span><span class="ansigrey">l</span><span class="ansigrey">o</span><span class="ansigrey"></span>',
62 62 'hel%slo' % TermColors.Green : 'hel<span class="ansigreen">lo</span>',
63 63 'hello' : 'hello'}
64 64
65 65 for inval, outval in correct_outputs.items():
66 66 yield self._try_ansi2html, inval, outval
67 67
68 68
69 69 def _try_ansi2html(self, inval, outval):
70 70 assert self.fuzzy_compare(outval, ansi2html(inval))
71 71
72 72
73 73 def test_ansi2latex(self):
74 74 """
75 75 ansi2latex test
76 76 """
77 77 correct_outputs = {
78 78 '%s' % (TermColors.Red) : r'\red{}',
79 79 'hello%s' % TermColors.Blue: r'hello\blue{}',
80 80 'he%s%sllo' % (TermColors.Green, TermColors.Cyan) : r'he\green{}\cyan{llo}',
81 81 '%shello' % TermColors.Yellow : r'\yellow{hello}',
82 82 '{0}h{0}e{0}l{0}l{0}o{0}'.format(TermColors.White) : r'\white{h}\white{e}\white{l}\white{l}\white{o}\white{}',
83 83 'hel%slo' % TermColors.Green : r'hel\green{lo}',
84 84 'hello' : 'hello'}
85 85
86 86 for inval, outval in correct_outputs.items():
87 87 yield self._try_ansi2latex, inval, outval
88 88
89 89
90 90 def _try_ansi2latex(self, inval, outval):
91 91 assert self.fuzzy_compare(outval, ansi2latex(inval), case_sensitive=True)
@@ -1,46 +1,46 b''
1 1 """
2 2 Module with tests for DataTypeFilter
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17
18 18 from ...tests.base import TestsBase
19 19 from ..datatypefilter import DataTypeFilter
20 20
21 21
22 22 #-----------------------------------------------------------------------------
23 23 # Class
24 24 #-----------------------------------------------------------------------------
25 25
26 class Test_DataTypeFilter(TestsBase):
26 class TestDataTypeFilter(TestsBase):
27 27 """Contains test functions for datatypefilter.py"""
28 28
29 29
30 30 def test_constructor(self):
31 31 """Can an instance of a DataTypeFilter be created?"""
32 32 DataTypeFilter()
33 33
34 34
35 35 def test_junk_types(self):
36 36 """Can the DataTypeFilter pickout a useful type from a list of junk types?"""
37 37 filter = DataTypeFilter()
38 38 assert filter(["hair", "water", "png", "rock"]) == ["png"]
39 39 assert filter(["pdf", "hair", "water", "png", "rock"]) == ["pdf"]
40 40 assert filter(["hair", "water", "rock"]) == []
41 41
42 42
43 43 def test_null(self):
44 44 """Will the DataTypeFilter fail if no types are passed in?"""
45 45 filter = DataTypeFilter()
46 46 assert filter([]) == []
@@ -1,35 +1,35 b''
1 1 """
2 2 Module with tests for Highlight
3 3 """
4 4
5 5 #-----------------------------------------------------------------------------
6 6 # Copyright (c) 2013, the IPython Development Team.
7 7 #
8 8 # Distributed under the terms of the Modified BSD License.
9 9 #
10 10 # The full license is in the file COPYING.txt, distributed with this software.
11 11 #-----------------------------------------------------------------------------
12 12
13 13 #-----------------------------------------------------------------------------
14 14 # Imports
15 15 #-----------------------------------------------------------------------------
16 16
17 17
18 18 from ...tests.base import TestsBase
19 19 from ..highlight import *
20 20
21 21
22 22 #-----------------------------------------------------------------------------
23 23 # Class
24 24 #-----------------------------------------------------------------------------
25 25
26 class Test_Highlight(TestsBase):
26 class TestHighlight(TestsBase):
27 27 """Contains test functions for highlight.py"""
28 28
29 29
30 30 def test_highlight(source, language='ipython'):
31 31 pass
32 32
33 33
34 34 def test_highlight2latex(source, language='ipython'):
35 35 pass
@@ -1,109 +1,109 b''
1 1 """
2 2 Contains tests for the nbconvertapp
3 3 """
4 4 #-----------------------------------------------------------------------------
5 5 #Copyright (c) 2013, the IPython Development Team.
6 6 #
7 7 #Distributed under the terms of the Modified BSD License.
8 8 #
9 9 #The full license is in the file COPYING.txt, distributed with this software.
10 10 #-----------------------------------------------------------------------------
11 11
12 12 #-----------------------------------------------------------------------------
13 13 # Imports
14 14 #-----------------------------------------------------------------------------
15 15
16 16 import os
17 17 from .base import TestsBase
18 18
19 19 #-----------------------------------------------------------------------------
20 20 # Classes and functions
21 21 #-----------------------------------------------------------------------------
22 22
23 class Test_NbConvertApp(TestsBase):
23 class TestNbConvertApp(TestsBase):
24 24 """Collection of NbConvertApp tests"""
25 25
26 26
27 27 def test_notebook_help(self):
28 28 """
29 29 Will help show if no notebooks are specified?
30 30 """
31 31 with self.create_temp_cwd():
32 32 assert "see '--help-all'" in self.call(['ipython', 'nbconvert'])
33 33
34 34
35 35 def test_glob(self):
36 36 """
37 37 Do search patterns work for notebook names?
38 38 """
39 39 with self.create_temp_cwd(['notebook*.ipynb']):
40 40 assert not 'error' in self.call(['ipython', 'nbconvert',
41 41 '--format="python"', '--notebooks=["*.ipynb"]']).lower()
42 42 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
43 43 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
44 44
45 45
46 46 def test_glob_subdir(self):
47 47 """
48 48 Do search patterns work for subdirectory notebook names?
49 49 """
50 50 with self.create_temp_cwd() as cwd:
51 51 self.copy_files_to(['notebook*.ipynb'], 'subdir/')
52 52 assert not 'error' in self.call(['ipython', 'nbconvert', '--format="python"',
53 53 '--notebooks=["%s"]' % os.path.join('subdir', '*.ipynb')]).lower()
54 54 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
55 55 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
56 56
57 57
58 58 def test_explicit(self):
59 59 """
60 60 Do explicit notebook names work?
61 61 """
62 62 with self.create_temp_cwd(['notebook*.ipynb']):
63 63 assert not 'error' in self.call(['ipython', 'nbconvert', '--format="python"',
64 64 '--notebooks=["notebook2.ipynb"]']).lower()
65 65 assert not os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
66 66 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
67 67
68 68
69 69 def test_glob_explicit(self):
70 70 """
71 71 Can a search pattern be used along with matching explicit notebook names?
72 72 """
73 73 with self.create_temp_cwd(['notebook*.ipynb']):
74 74 assert not 'error' in self.call(['ipython', 'nbconvert', '--format="python"',
75 75 '--notebooks=["*.ipynb", "notebook1.ipynb", "notebook2.ipynb"]']).lower()
76 76 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
77 77 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
78 78
79 79
80 80 def test_explicit_glob(self):
81 81 """
82 82 Can explicit notebook names be used and then a matching search pattern?
83 83 """
84 84 with self.create_temp_cwd(['notebook*.ipynb']):
85 85 assert not 'error' in self.call(['ipython', 'nbconvert', '--format="python"',
86 86 '--notebooks=["notebook1.ipynb", "notebook2.ipynb", "*.ipynb"]']).lower()
87 87 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
88 88 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
89 89
90 90
91 91 def test_default_config(self):
92 92 """
93 93 Does the default config work?
94 94 """
95 95 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py']):
96 96 assert not 'error' in self.call(['ipython', 'nbconvert']).lower()
97 97 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
98 98 assert not os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
99 99
100 100
101 101 def test_override_config(self):
102 102 """
103 103 Can the default config be overriden?
104 104 """
105 105 with self.create_temp_cwd(['notebook*.ipynb', 'ipython_nbconvert_config.py',
106 106 'override.py']):
107 107 assert not 'error' in self.call(['ipython', 'nbconvert', '--config="override.py"']).lower()
108 108 assert not os.path.isfile(os.path.join('nbconvert_build', 'notebook1.py'))
109 109 assert os.path.isfile(os.path.join('nbconvert_build', 'notebook2.py'))
General Comments 0
You need to be logged in to leave comments. Login now