Show More
@@ -1,58 +1,75 b'' | |||
|
1 | 1 | import io |
|
2 | 2 | import nose.tools as nt |
|
3 | import os | |
|
3 | 4 | from nose.tools import nottest |
|
4 | 5 | from converters import ( |
|
5 | 6 | ConverterLaTeX, ConverterMarkdown, ConverterPy, ConverterHTML, |
|
6 | 7 | ConverterReveal |
|
7 | 8 | ) |
|
8 | 9 | |
|
9 | 10 | @nottest |
|
10 | 11 | def cleanfile(stn): |
|
11 | 12 | return filter(None, map(unicode.strip, stn.split('\n'))) |
|
12 | 13 | |
|
14 | @nottest | |
|
15 | def skipiftravis(func): | |
|
16 | if os.getenv('TRAVIS') == True: | |
|
17 | func.__test__ = False | |
|
18 | return func | |
|
19 | ||
|
20 | @nottest | |
|
21 | def is_travis(): | |
|
22 | return os.getenv('TRAVIS') == 'true' | |
|
23 | ||
|
24 | @nottest | |
|
25 | def is_not_travis(): | |
|
26 | return not is_travis() | |
|
27 | ||
|
13 | 28 | |
|
14 | 29 | def test_evens(): |
|
15 | 30 | ###### |
|
16 | 31 | # for now, we don't need to really run inkscape to extract svg |
|
17 | 32 | # from file, on unix, for test, we monkeypathc it to 'true' |
|
18 | 33 | # which does not fail as doing anything. |
|
19 | 34 | #### |
|
20 | 35 | ConverterLaTeX.inkscape = 'true' |
|
21 | 36 | |
|
22 | 37 | # commenting rst for now as travis build |
|
23 | 38 | # fail because of pandoc version. |
|
24 | 39 | converters = [ |
|
25 | 40 | #(ConverterRST, 'rst'), |
|
26 | 41 | (ConverterMarkdown, 'md'), |
|
27 | 42 | (ConverterLaTeX, 'tex'), |
|
28 | 43 | (ConverterPy, 'py'), |
|
29 | (ConverterHTML, 'html') | |
|
30 | 44 | ] |
|
45 | if is_not_travis() : | |
|
46 | converters.append((ConverterHTML, 'html')) | |
|
47 | ||
|
31 | 48 | reflist = [ |
|
32 | 49 | 'tests/ipynbref/IntroNumPy.orig' |
|
33 | 50 | ] |
|
34 | 51 | for root in reflist: |
|
35 | 52 | for conv, ext in converters: |
|
36 | 53 | yield test_conversion, conv, root + '.ipynb', root + '.' + ext |
|
37 | 54 | |
|
38 | 55 | |
|
39 | 56 | def test_reveal(): |
|
40 | 57 | conv = ConverterReveal |
|
41 | 58 | root = 'tests/ipynbref/reveal.orig' |
|
42 | 59 | return test_conversion, conv, root + '.ipynb', root + '_slides.' + 'html' |
|
43 | 60 | |
|
44 | 61 | |
|
45 | 62 | @nottest |
|
46 | 63 | def compfiles(stra, strb): |
|
47 | 64 | nt.assert_equal(cleanfile(stra), |
|
48 | 65 | cleanfile(strb)) |
|
49 | 66 | |
|
50 | 67 | |
|
51 | 68 | @nottest |
|
52 | 69 | def test_conversion(ConverterClass, ipynb, ref_file): |
|
53 | 70 | converter = ConverterClass(infile=ipynb) |
|
54 | 71 | converter.read() |
|
55 | 72 | cv = converter.convert() |
|
56 | 73 | with io.open(ref_file) as ref: |
|
57 | 74 | value = ref.read() |
|
58 | 75 | compfiles(cv, value) |
General Comments 0
You need to be logged in to leave comments.
Login now