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

fijal at codespeak.net fijal at codespeak.net
Wed Feb 7 21:57:04 CET 2007


Author: fijal
Date: Wed Feb  7 21:56:51 2007
New Revision: 38121

Modified:
   py/trunk/py/rest/testing/test_directive.py
Log:
Same issue. Race conditions in file write. Probably we should not use
the same file output for multiple tests (or to put data directory outside
pylib itself).



Modified: py/trunk/py/rest/testing/test_directive.py
==============================================================================
--- py/trunk/py/rest/testing/test_directive.py	(original)
+++ py/trunk/py/rest/testing/test_directive.py	Wed Feb  7 21:56:51 2007
@@ -11,36 +11,41 @@
 datadir = py.magic.autopath().dirpath().join("data")
 testdir = py.test.ensuretemp("rest")
 
-def test_graphviz_html():
-    if not py.path.local.sysfind("dot"):
-        py.test.skip("graphviz needed")
-    directive.set_backend_and_register_directives("html")
-    if not py.path.local.sysfind("svn"):
-        py.test.skip("svn needed")
-    txt = datadir.join("graphviz.txt")
-    html = txt.new(ext="html")
-    png = datadir.join("example1.png")
-    rest.process(txt)
-    assert html.check()
-    assert png.check()
-    html_content = html.read()
-    assert png.basename in html_content
-    html.remove()
-    png.remove()
+class TestGraphviz(object):
+    def _graphviz_html(self):
+        if not py.path.local.sysfind("dot"):
+            py.test.skip("graphviz needed")
+        directive.set_backend_and_register_directives("html")
+        if not py.path.local.sysfind("svn"):
+            py.test.skip("svn needed")
+        txt = datadir.join("graphviz.txt")
+        html = txt.new(ext="html")
+        png = datadir.join("example1.png")
+        rest.process(txt)
+        assert html.check()
+        assert png.check()
+        html_content = html.read()
+        assert png.basename in html_content
+        html.remove()
+        png.remove()
+        
+    def _graphviz_pdf(self):
+        if not py.path.local.sysfind("dot") or not py.path.local.sysfind("latex"):
+            py.test.skip("graphviz and latex needed")
 
-def test_graphviz_pdf():
-    if not py.path.local.sysfind("dot") or not py.path.local.sysfind("latex"):
-        py.test.skip("graphviz and latex needed")
+        directive.set_backend_and_register_directives("latex")
+        txt = py.path.local(datadir.join("graphviz.txt"))
+        pdf = txt.new(ext="pdf")
+        dotpdf = datadir.join("example1.pdf")
+        process_rest_file(txt)
+        assert pdf.check()
+        assert dotpdf.check()
+        pdf.remove()
+        dotpdf.remove()
 
-    directive.set_backend_and_register_directives("latex")
-    txt = py.path.local(datadir.join("graphviz.txt"))
-    pdf = txt.new(ext="pdf")
-    dotpdf = datadir.join("example1.pdf")
-    process_rest_file(txt)
-    assert pdf.check()
-    assert dotpdf.check()
-    pdf.remove()
-    dotpdf.remove()
+    def test_graphviz(self):
+        self._graphviz_html()
+        self._graphviz_pdf()
 
 def test_own_links():
     def callback(name, text):



More information about the pytest-commit mailing list