[py-svn] r21134 - in py/dist/py/rest: . testing testing/data
cfbolz at codespeak.net
cfbolz at codespeak.net
Tue Dec 13 15:53:33 CET 2005
Author: cfbolz
Date: Tue Dec 13 15:53:31 2005
New Revision: 21134
Modified:
py/dist/py/rest/latex.py
py/dist/py/rest/testing/data/example.rst2pdfconfig
py/dist/py/rest/testing/test_rst2pdf.py
Log:
allow passing of options into rest within a rst2pdfconfig file by using
rest_options = [...]. test for this
Modified: py/dist/py/rest/latex.py
==============================================================================
--- py/dist/py/rest/latex.py (original)
+++ py/dist/py/rest/latex.py Tue Dec 13 15:53:31 2005
@@ -87,7 +87,10 @@
sty = configfile.new(ext='sty')
content = create_stylesheet(configfile_dic, path)
sty.write(content)
- process_rest_file(rest, sty.basename, debug)
+ rest_options = None
+ if 'rest_options' in configfile_dic:
+ rest_options = configfile_dic['rest_options']
+ process_rest_file(rest, sty.basename, debug, rest_options)
#cleanup:
if not debug:
sty.remove()
@@ -95,7 +98,7 @@
rest.remove()
old.chdir()
-def process_rest_file(restfile, stylesheet=None, debug=False):
+def process_rest_file(restfile, stylesheet=None, debug=False, rest_options=None):
old = py.path.local()
f = py.path.local(restfile)
path = f.dirpath()
@@ -111,6 +114,8 @@
options.append("--stylesheet=%s" % (sty, ))
options.append(f.new(basename=tex))
options = map(str, options)
+ if rest_options is not None:
+ options.extend(rest_options)
publish_cmdline(writer_name='latex', argv=options)
for i in range(2):
#XXX sometimes pdflatex has to be run several time
Modified: py/dist/py/rest/testing/data/example.rst2pdfconfig
==============================================================================
--- py/dist/py/rest/testing/data/example.rst2pdfconfig (original)
+++ py/dist/py/rest/testing/data/example.rst2pdfconfig Tue Dec 13 15:53:31 2005
@@ -1,2 +1,3 @@
rest_sources = ['part1.txt', 'part2.txt']
+rest_options = ["--generator"] # easy to test
Modified: py/dist/py/rest/testing/test_rst2pdf.py
==============================================================================
--- py/dist/py/rest/testing/test_rst2pdf.py (original)
+++ py/dist/py/rest/testing/test_rst2pdf.py Tue Dec 13 15:53:31 2005
@@ -13,6 +13,14 @@
def test_process_configfile():
config = data.join("example.rst2pdfconfig")
pdf = config.new(ext="pdf")
- process_configfile(config)
+ tex = data.join('example.tex')
+ process_configfile(config, debug=True)
assert pdf.check()
+ assert tex.check()
+ texcontent = tex.read()
+ assert "Generated by" in texcontent
+ assert "Docutils" in texcontent
+ process_configfile(config, debug=False)
+ assert pdf.check()
+ assert not tex.check()
pdf.remove()
More information about the pytest-commit
mailing list