[py-svn] r38120 - py/trunk/py/rest/testing

fijal at codespeak.net fijal at codespeak.net
Wed Feb 7 21:54:03 CET 2007


Author: fijal
Date: Wed Feb  7 21:53:57 2007
New Revision: 38120

Modified:
   py/trunk/py/rest/testing/test_rst2pdf.py
Log:
Make sure that those test run on same machine when run.
(This is broader issue - we probably need to do some exclusive
lock on files given to process_rest_file and such)


Modified: py/trunk/py/rest/testing/test_rst2pdf.py
==============================================================================
--- py/trunk/py/rest/testing/test_rst2pdf.py	(original)
+++ py/trunk/py/rest/testing/test_rst2pdf.py	Wed Feb  7 21:53:57 2007
@@ -13,36 +13,44 @@
            not py.path.local.sysfind("dot") or \
            not py.path.local.sysfind("latex"):
         py.test.skip("ghostscript, graphviz and latex needed")
+    mod.data = py.magic.autopath().dirpath().join("data")
 
-data = py.magic.autopath().dirpath().join("data")
+class TestRst2Pdf(object):
+    def _process_rest_file(self):
+        data = py.magic.autopath().dirpath().join("data")
+        part2 = data.join("part1.txt")
+        pdf = part2.new(ext="pdf")
+        process_rest_file(part2)
+        assert pdf.check()
+        pdf.remove()
 
-def test_process_rest_file():
-    part2 = data.join("part1.txt")
-    pdf = part2.new(ext="pdf")
-    process_rest_file(part2)
-    assert pdf.check()
-    pdf.remove()
+    def _process_configfile(self):
+        data = py.magic.autopath().dirpath().join("data")
+        config = data.join("example.rst2pdfconfig")
+        pdf = config.new(ext="pdf")
+        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()
 
-def test_process_configfile():
-    config = data.join("example.rst2pdfconfig")
-    pdf = config.new(ext="pdf")
-    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()
+    def _process_all(self):
+        # fallback test: only checks that no exception is raised
+        def rec(p):
+            return p.check(dotfile=0)
 
-def test_process_all():
-    # fallback test: only checks that no exception is raised
-    def rec(p):
-        return p.check(dotfile=0)
-    for x in data.visit("*.txt", rec=rec):
-        yield process_rest_file, x
-    for x in data.visit("*.rst2pdfconfig", rec=rec):
-        yield process_configfile, x
+        for x in data.visit("*.rst2pdfconfig", rec=rec):
+            process_configfile(x)
+        for x in data.visit("*.txt", rec=rec):
+            process_rest_file(x)
+
+    def test_rst2pdf(self):
+        self._process_rest_file()
+        self._process_configfile()
+        self._process_all()


More information about the py-svn mailing list