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