[pypy-commit] pypy default: make the syntax tree viewer use mkdtemp+remove after run when pytest.ensuretemp is not availiable (i.e. outside of testrun)

RonnyPfannschmidt noreply at buildbot.pypy.org
Tue Aug 30 12:33:08 CEST 2011


Author: Ronny Pfannschmidt <Ronny.Pfannschmidt at gmx.de>
Branch: 
Changeset: r46920:bf7e78a0e3ac
Date: 2011-08-30 12:29 +0200
http://bitbucket.org/pypy/pypy/changeset/bf7e78a0e3ac/

Log:	make the syntax tree viewer use mkdtemp+remove after run when
	pytest.ensuretemp is not availiable (i.e. outside of testrun)

diff --git a/pypy/rlib/parsing/tree.py b/pypy/rlib/parsing/tree.py
--- a/pypy/rlib/parsing/tree.py
+++ b/pypy/rlib/parsing/tree.py
@@ -6,9 +6,16 @@
         content = ["digraph G{"]
         content.extend(self.dot())
         content.append("}")
-        p = py.test.ensuretemp("automaton").join("temp.dot")
+        try:
+            p = py.test.ensuretemp("automaton").join("temp.dot")
+            remove = False
+        except AttributeError: # pytest lacks ensuretemp, make a normal one
+            p = py.path.local.mkdtemp().join('automaton.dot')
+            remove = True
         p.write("\n".join(content))
         graphclient.display_dot_file(str(p))
+        if remove:
+            p.dirpath().remove()
 
 class Symbol(Node):
 


More information about the pypy-commit mailing list