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