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