##// END OF EJS Templates
Convert parent handle to an int before setting environment variable...
Convert parent handle to an int before setting environment variable Should fix Windows & Python 2 test failures

File last commit:

r19048:20479ca1
r19294:c928f4bc
Show More
test_svg2pdf.py
73 lines | 2.3 KiB | text/x-python | PythonLexer
MinRK
update nbconvert to nbformat 4
r18580 """Tests for the svg2pdf preprocessor"""
Jonathan Frederic
Add svg2pdf transformer tests
r12034
MinRK
update nbconvert to nbformat 4
r18580 # Copyright (c) IPython Development Team.
Jonathan Frederic
Add svg2pdf transformer tests
r12034 # Distributed under the terms of the Modified BSD License.
from IPython.testing import decorators as dec
MinRK
Don't use nbformat.current in nbconvert
r18605 from IPython.nbformat import v4 as nbformat
Jonathan Frederic
Add svg2pdf transformer tests
r12034
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 from .base import PreprocessorTestsBase
from ..svg2pdf import SVG2PDFPreprocessor
Jonathan Frederic
Add svg2pdf transformer tests
r12034
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 class Testsvg2pdf(PreprocessorTestsBase):
Jonathan Frederic
Add svg2pdf transformer tests
r12034 """Contains test functions for svg2pdf.py"""
simple_svg = """<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.0"
x="0.00000000"
y="0.00000000"
width="500.00000"
height="500.00000"
id="svg2">
<defs
id="defs4" />
<g
id="layer1">
<rect
width="300.00000"
height="300.00000"
x="100.00000"
y="100.00000"
style="opacity:1.0000000;fill:none;fill-opacity:1.0000000;fill-rule:evenodd;stroke:#000000;stroke-width:8.0000000;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4.0000000;stroke-dasharray:none;stroke-dashoffset:0.00000000;stroke-opacity:1.0000000"
id="rect5719" />
</g>
</svg>"""
def build_notebook(self):
MinRK
address review from takluyver...
r18602 """Build a reveal slides notebook in memory for use with tests.
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 Overrides base in PreprocessorTestsBase"""
Jonathan Frederic
Add svg2pdf transformer tests
r12034
Thomas Kluyver
Fix test for svg2pdf preprocessor
r19047 outputs = [nbformat.new_output(output_type='display_data',
data={'image/svg+xml':self.simple_svg})
]
Jonathan Frederic
Add svg2pdf transformer tests
r12034
MinRK
s/prompt_number/execution_count in nbformat 4
r18587 cells=[nbformat.new_code_cell(source="", execution_count=1, outputs=outputs)]
Jonathan Frederic
Add svg2pdf transformer tests
r12034
MinRK
update nbconvert to nbformat 4
r18580 return nbformat.new_notebook(cells=cells)
Jonathan Frederic
Add svg2pdf transformer tests
r12034
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 def build_preprocessor(self):
"""Make an instance of a preprocessor"""
preprocessor = SVG2PDFPreprocessor()
preprocessor.enabled = True
return preprocessor
Jonathan Frederic
Fixes small things pointed out by @minrk
r12035
def test_constructor(self):
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 """Can a SVG2PDFPreprocessor be constructed?"""
self.build_preprocessor()
Jonathan Frederic
Expanded transformer pass line, for easier debugging
r12039
Jonathan Frederic
Add svg2pdf transformer tests
r12034
@dec.onlyif_cmds_exist('inkscape')
def test_output(self):
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 """Test the output of the SVG2PDFPreprocessor"""
Jonathan Frederic
Expanded transformer pass line, for easier debugging
r12039 nb = self.build_notebook()
res = self.build_resources()
Paul Ivanov
replace 'transformer' with 'preprocessor'
r12219 preprocessor = self.build_preprocessor()
nb, res = preprocessor(nb, res)
Thomas Kluyver
Fix test for svg2pdf preprocessor
r19047 self.assertIn('application/pdf', nb.cells[0].outputs[0].data)