##// END OF EJS Templates
Improve test for nbconvert citation filter....
Thomas Kluyver -
Show More
@@ -1,58 +1,59 b''
1 #-----------------------------------------------------------------------------
1 #-----------------------------------------------------------------------------
2 # Copyright (c) 2013, the IPython Development Team.
2 # Copyright (c) 2013, the IPython Development Team.
3 #
3 #
4 # Distributed under the terms of the Modified BSD License.
4 # Distributed under the terms of the Modified BSD License.
5 #
5 #
6 # The full license is in the file COPYING.txt, distributed with this software.
6 # The full license is in the file COPYING.txt, distributed with this software.
7 #-----------------------------------------------------------------------------
7 #-----------------------------------------------------------------------------
8
8
9 #-----------------------------------------------------------------------------
9 #-----------------------------------------------------------------------------
10 # Imports
10 # Imports
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 from ..citation import citation2latex
13 from ..citation import citation2latex
14 from nose.tools import assert_equal
14
15
15 #-----------------------------------------------------------------------------
16 #-----------------------------------------------------------------------------
16 # Tests
17 # Tests
17 #-----------------------------------------------------------------------------
18 #-----------------------------------------------------------------------------
18
19
19 test_md = """
20 test_md = """
20 # My Heading
21 # My Heading
21
22
22 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
23 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
23 porttitor scelerisque ac id diam <cite data-cite="granger">Granger</cite>. Mauris elit
24 porttitor scelerisque ac id diam <cite data-cite="granger">Granger</cite>. Mauris elit
24 velit, lobortis sed interdum at, vestibulum vitae libero <strong data-cite="fperez">Perez</strong>.
25 velit, lobortis sed interdum at, vestibulum vitae libero <strong data-cite="fperez">Perez</strong>.
25 Lorem ipsum dolor sit amet, consectetur adipiscing elit
26 Lorem ipsum dolor sit amet, consectetur adipiscing elit
26 <em data-cite="takluyver">Thomas</em>. Quisque iaculis ligula ut ipsum mattis viverra.
27 <em data-cite="takluyver">Thomas</em>. Quisque iaculis ligula ut ipsum mattis viverra.
27
28
28 <p>Here is a plain paragraph that should be unaffected.</p>
29 <p>Here is a plain paragraph that should be unaffected.</p>
29
30
30 * One <cite data-cite="jdfreder">Jonathan</cite>.
31 * One <cite data-cite="jdfreder">Jonathan</cite>.
31 * Two <cite data-cite="carreau">Matthias</cite>.
32 * Two <cite data-cite="carreau">Matthias</cite>.
32 * Three <cite data-cite="ivanov">Paul</cite>.
33 * Three <cite data-cite="ivanov">Paul</cite>.
33 """
34 """
34
35
35 test_md_parsed = """
36 test_md_parsed = """
36 # My Heading
37 # My Heading
37
38
38 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
39 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ac magna non augue
39 porttitor scelerisque ac id diam \cite{granger}. Mauris elit
40 porttitor scelerisque ac id diam \cite{granger}. Mauris elit
40 velit, lobortis sed interdum at, vestibulum vitae libero \cite{fperez}.
41 velit, lobortis sed interdum at, vestibulum vitae libero \cite{fperez}.
41 Lorem ipsum dolor sit amet, consectetur adipiscing elit
42 Lorem ipsum dolor sit amet, consectetur adipiscing elit
42 \cite{takluyver}. Quisque iaculis ligula ut ipsum mattis viverra.
43 \cite{takluyver}. Quisque iaculis ligula ut ipsum mattis viverra.
43
44
44 <p>Here is a plain paragraph that should be unaffected.</p>
45 <p>Here is a plain paragraph that should be unaffected.</p>
45
46
46 * One \cite{jdfreder}.
47 * One \cite{jdfreder}.
47 * Two \cite{carreau}.
48 * Two \cite{carreau}.
48 * Three \cite{ivanov}.
49 * Three \cite{ivanov}.
49 """
50 """
50
51
51 def test_citation2latex():
52 def test_citation2latex():
52 """Are citations parsed properly?"""
53 """Are citations parsed properly?"""
53 try:
54 try:
54 import lxml
55 from lxml import html #analysis:ignore
55 except ImportError:
56 except ImportError:
56 assert test_md == citation2latex(test_md)
57 assert_equal(test_md, citation2latex(test_md))
57 else:
58 else:
58 assert test_md_parsed == citation2latex(test_md)
59 assert_equal(test_md_parsed, citation2latex(test_md))
General Comments 0
You need to be logged in to leave comments. Login now