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