[py-svn] r62998 - in py/trunk/py/test: plugin testing

hpk at codespeak.net hpk at codespeak.net
Tue Mar 17 14:10:19 CET 2009


Author: hpk
Date: Tue Mar 17 14:10:17 2009
New Revision: 62998

Modified:
   py/trunk/py/test/plugin/pytest_tmpdir.py
   py/trunk/py/test/testing/acceptance_test.py
Log:
tweak another place to not create random subdirs


Modified: py/trunk/py/test/plugin/pytest_tmpdir.py
==============================================================================
--- py/trunk/py/test/plugin/pytest_tmpdir.py	(original)
+++ py/trunk/py/test/plugin/pytest_tmpdir.py	Tue Mar 17 14:10:17 2009
@@ -13,19 +13,9 @@
     """ provide temporary directories to test functions and methods. 
     """ 
 
-    def pytest_configure(self, config):
-        # XXX make ensuretemp live on config 
-        self.basetmp = py.test.ensuretemp("tmpdir")
-
     def pytest_pyfuncarg_tmpdir(self, pyfuncitem):
         name = pyfuncitem.name
-        for i in range(10000):
-            try:
-                tmpdir = self.basetmp.mkdir(name + (i and str(i) or ''))
-            except py.error.EEXIST:
-                continue
-            break
-        return tmpdir
+        return pyfuncitem._config.mktemp(name, numbered=True)
 
 # ===============================================================================
 #
@@ -39,8 +29,7 @@
 def test_pyfuncarg(testdir):
     item = testdir.getitem("def test_func(tmpdir): pass")
     plugin = TmpdirPlugin()
-    plugin.pytest_configure(item._config)
     p = plugin.pytest_pyfuncarg_tmpdir(item)
     assert p.check()
-    bn = p.basename.strip("0123456789")
+    bn = p.basename.strip("0123456789-")
     assert bn.endswith("test_func")

Modified: py/trunk/py/test/testing/acceptance_test.py
==============================================================================
--- py/trunk/py/test/testing/acceptance_test.py	(original)
+++ py/trunk/py/test/testing/acceptance_test.py	Tue Mar 17 14:10:17 2009
@@ -373,7 +373,9 @@
 class TestInteractive:
     def getspawn(self, tmpdir):
         pexpect = py.test.importorskip("pexpect")
+        basetemp = tmpdir.mkdir("basetemp")
         def spawn(cmd):
+            cmd = cmd + " --basetemp=" + str(basetemp)
             return pexpect.spawn(cmd, logfile=tmpdir.join("spawn.out").open("w"))
         return spawn
 
@@ -391,7 +393,6 @@
                 i = 0
                 assert i == 1
         """)
-       
         child = spawn("%s %s --pdb %s" % (py.std.sys.executable, pytestpath, p1))
         child.timeout = EXPECTTIMEOUT
         #child.expect(".*def test_1.*")



More information about the pytest-commit mailing list