##// END OF EJS Templates
Fixed spacing in pandoc tests
Jonathan Frederic -
Show More
@@ -1,74 +1,63 b''
1 """Test Pandoc module"""
1 """Test Pandoc module"""
2
2
3 #-----------------------------------------------------------------------------
3 #-----------------------------------------------------------------------------
4 # Copyright (C) 2013 The IPython Development Team
4 # Copyright (C) 2014 The IPython Development Team
5 #
5 #
6 # Distributed under the terms of the BSD License. The full license is in
6 # Distributed under the terms of the BSD License. The full license is in
7 # the file COPYING, distributed as part of this software.
7 # the file COPYING, distributed as part of this software.
8 #-----------------------------------------------------------------------------
8 #-----------------------------------------------------------------------------
9
9
10 #-----------------------------------------------------------------------------
10 #-----------------------------------------------------------------------------
11 # Imports
11 # Imports
12 #-----------------------------------------------------------------------------
12 #-----------------------------------------------------------------------------
13
14 import os
13 import os
15
14
16 from .base import TestsBase
17 from ..utils import pandoc
18
19 from IPython.testing import decorators as dec
15 from IPython.testing import decorators as dec
20
16
21 #-----------------------------------------------------------------------------
17 from .base import TestsBase
22 # Constants
18 from ..utils import pandoc
23 #-----------------------------------------------------------------------------
24
25
19
26 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
27 # Classes and functions
21 # Classes and functions
28 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
29
30
31 class TestPandoc(TestsBase):
23 class TestPandoc(TestsBase):
32 """Collection of Pandoc tests"""
24 """Collection of Pandoc tests"""
33
25
34 def __init__(self, *args, **kwargs):
26 def __init__(self, *args, **kwargs):
35 super(TestPandoc, self).__init__(*args, **kwargs)
27 super(TestPandoc, self).__init__(*args, **kwargs)
36 self.original_env = os.environ.copy()
28 self.original_env = os.environ.copy()
37
29
38 @dec.onlyif_cmds_exist('pandoc')
30 @dec.onlyif_cmds_exist('pandoc')
39 def test_pandoc_available(self):
31 def test_pandoc_available(self):
40 """ Test behaviour that pandoc functions raise PandocMissing as documented """
32 """ Test behaviour that pandoc functions raise PandocMissing as documented """
41 pandoc.clean_cache()
33 pandoc.clean_cache()
42
34
43 os.environ["PATH"] = ""
35 os.environ["PATH"] = ""
44 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == True
36 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == True
45 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == True
37 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == True
46 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == True
38 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == True
47
39
48 # original_env["PATH"] should contain pandoc
40 # original_env["PATH"] should contain pandoc
49 os.environ["PATH"] = self.original_env["PATH"]
41 os.environ["PATH"] = self.original_env["PATH"]
50 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == False
42 assert pandoc_function_raised_missing(pandoc.get_pandoc_version) == False
51 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == False
43 assert pandoc_function_raised_missing(pandoc.check_pandoc_version) == False
52 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == False
44 assert pandoc_function_raised_missing(pandoc.pandoc, "", "markdown", "html") == False
53
45
54
55 @dec.onlyif_cmds_exist('pandoc')
46 @dec.onlyif_cmds_exist('pandoc')
56 def test_minimal_version(self):
47 def test_minimal_version(self):
57 original_minversion = pandoc._minimal_version
48 original_minversion = pandoc._minimal_version
58
49
59 pandoc._minimal_version = "120.0"
50 pandoc._minimal_version = "120.0"
60 assert not pandoc.check_pandoc_version()
51 assert not pandoc.check_pandoc_version()
61
52
62 pandoc._minimal_version = pandoc.get_pandoc_version()
53 pandoc._minimal_version = pandoc.get_pandoc_version()
63 assert pandoc.check_pandoc_version()
54 assert pandoc.check_pandoc_version()
64
55
65
56
66
67
68 def pandoc_function_raised_missing(f, *args, **kwargs):
57 def pandoc_function_raised_missing(f, *args, **kwargs):
69 try:
58 try:
70 f(*args, **kwargs)
59 f(*args, **kwargs)
71 except pandoc.PandocMissing:
60 except pandoc.PandocMissing:
72 return True
61 return True
73 else:
62 else:
74 return False
63 return False
General Comments 0
You need to be logged in to leave comments. Login now