[py-svn] r7055 - in py/dist: doc py/path py/path/local py/path/local/popen5 py/path/svn py/path/test py/test

hpk at codespeak.net hpk at codespeak.net
Wed Oct 20 02:57:44 CEST 2004


Author: hpk
Date: Wed Oct 20 02:57:43 2004
New Revision: 7055

Added:
   py/dist/py/path/local/popen5/   (props changed)
   py/dist/py/path/local/popen5/__init__.py
   py/dist/py/path/local/popen5/_subprocess.c
      - copied unchanged from r7054, vendor/popen5/_subprocess.c
   py/dist/py/path/local/popen5/subprocess.py
      - copied unchanged from r7054, vendor/popen5/subprocess.py
   py/dist/py/path/local/popen5/test_subprocess.py
      - copied, changed from r7054, vendor/popen5/test_subprocess.py
Modified:
   py/dist/doc/execnet.txt
   py/dist/doc/future.txt
   py/dist/doc/misc.txt
   py/dist/py/path/common.py
   py/dist/py/path/local/local.py
   py/dist/py/path/local/posix.py
   py/dist/py/path/local/test_local.py
   py/dist/py/path/svn/svntestbase.py
   py/dist/py/path/test/common.py
   py/dist/py/path/test/fscommon.py
   py/dist/py/test/raises.py
   py/dist/py/test/run.py
Log:
- some more of the future is there

- a local path now has sysfind() and sysexec() 
  the latter based on code copied from the popen5-vendor
  branch. note that the _subprocess.c file is also available but
  not honoured in any way so far.  We want to have a transparent
  compile for this one. 

- moved future documentation to the misc-text accordingly 

- improved the local-path test handling slightly 

- fixed some small issues here and there 

- the cmdexec/sysexec Exception needs some refactoring and the
  whole 'process' business may need reconsideration because we
  could put a "shellexec" on a local path as well after which
  there may be no reason for the whole 'process' namespace anymore. 



Modified: py/dist/doc/execnet.txt
==============================================================================
--- py/dist/doc/execnet.txt	(original)
+++ py/dist/doc/execnet.txt	Wed Oct 20 02:57:43 2004
@@ -113,8 +113,8 @@
     #
     # API for sending and receiving anonymous values
     #
-    channel.send(*items): 
-        sends the given items to the other side of the channel, 
+    channel.send(item): 
+        sends the given item to the other side of the channel, 
         possibly blocking if the sender queue is full. 
         Note that each value V of the items needs to have the
         following property (all basic types in python have it):
@@ -134,7 +134,6 @@
         reraised as gateway.RemoteError exceptions containing 
         a textual representation of the remote traceback. 
 
-
 A simple and useful Example for Channels 
 ........................................ 
 

Modified: py/dist/doc/future.txt
==============================================================================
--- py/dist/doc/future.txt	(original)
+++ py/dist/doc/future.txt	Wed Oct 20 02:57:43 2004
@@ -12,6 +12,7 @@
 so read with some caution.  This is not a reference guide
 (tm).* 
 
+.. _`general-path`: 
 .. _`a more general view on path objects`:
 
 A more general view on ``py.path`` objects 
@@ -280,88 +281,15 @@
 
 .. _`py.execnet`: execnet.html 
 .. _`wrapping techniques PyPy uses`: http://codespeak.net/pypy/index.cgi?doc/wrapping.html
+.. _`lightweight xml generation`: 
 
+Extension of the py.path.local.sysexec()
+========================================
 
-Supporting interaction with system utilities/binaries
-=====================================================
-
-Currently, the py lib offers a simple way to interact with 
-executables in shell style::
-
-    out = py.process.cmdexec('ls -v')
-
-which will raise an exception in case of a return-code other than 0
-and otherwise return the output of the child process. 
-
-shortcomings of the current approach
-------------------------------------
-
-However, the ``cmdexec`` approach has a few shortcomings: 
-
-- it relies on the underlying system shell
-- it neccessitates shell-escaping for expressing arguments
-- it does not easily allow to "fix" the binary you want to run.  
-- it only allows to execute executables from the local 
-  filesystem 
-
-path objects come to rescue 
----------------------------
-
-We probably want to offer a stripped down functionality of what
-the new `PEP-324 subprocess module`_ offers.  The main functionality 
-of synchronously executing [#]_ a system executable should have a 
-straightforward api, maybe:: 
-
-    binsvn.execute('ls', 'http://codespeak.net/svn') 
-
-where ``binsvn`` is a path that points to the ``svn`` commandline
-binary. Note that this function would not offer any shell-escaping
-so you really have to pass in separated arguments.  This idea
-fits nicely into `a more general view on path objects`_. 
-
-For a first go, we could simply reuse the existing `subprocess
-implementation`_ but would not expose any of its API apart
-from the above "execute()" method. 
-
-.. [#] of course we could also think about replicating the `channel api`_
-       of gateways and return a special ``Channel`` object where you 
-       could call ``receive()`` and ``send()`` on. But these methods 
-       probably don't really fit here. Hum, food for thought. 
-      
-.. _`channel api`: execnet.html#channel-api 
-
-finding an executable
----------------------
-
-Finding an executable is quite different on multiple platforms. 
-At least, the ``PATH`` environment variable based search on
-unix platforms should be supported with something like::
-
-    py.path.local.sysfind('svn') 
-
-which would return the first path found to the ``svn`` exectuable. 
-In principle, 'sysfind' deploys platform specific algorithms
-to perform the search.  On Windows, for example, it may look
-at the registry. 
-
-To make the story complete, we can allow to pass in a "checker"
-that would be called for each found executable.  For example, 
-if you have multiple binaries available you may want to select 
-the right version:: 
-
-    def mysvn(p):
-        """ check that the given svn binary has version 1.1. """
-        line = p.execute('--version'').readlines()[0]
-        if line.find('version 1.1'): 
-            return p 
-
-    py.path.local.sysfind('svn', checker=mysvn) 
-
-world wide subversive interaction?
-----------------------------------
-
-While we are at it, we may want to run python scripts from 
-the net::
+The `sysexec mechanism`_ allows to directly execute 
+binaries on your system.  Especially after we'll have this
+nicely integrated into Win32 we may also want to run python 
+scripts both locally and from the net::
 
     vadm = py.path.svnurl('http://codespeak.net/svn/vadm/dist/vadm/cmdline.py') 
     stdoutput = vadm.execute('diff')
@@ -379,10 +307,9 @@
   interesting can of worms, suitable for another chapter
   in the neverending `future book`_. 
 
+.. _`sysexec mechanism`: misc.html#sysexec
 
 
-.. _`lightweight xml generation`: 
-
 Lightweight, convenient xml generation 
 ======================================
 

Modified: py/dist/doc/misc.txt
==============================================================================
--- py/dist/doc/misc.txt	(original)
+++ py/dist/doc/misc.txt	Wed Oct 20 02:57:43 2004
@@ -81,3 +81,85 @@
 be imported in any case. 
 
 .. _`the relative/absolute import PEP-328`: http://www.python.org/peps/pep-0328.html
+
+Supporting interaction with system utilities/binaries
+=====================================================
+
+Currently, the py lib offers two ways to interact with
+system executables. ``py.process.cmdexec()`` invokes
+the shell in order to execute a string.  The other
+one lets you directly execute a binary (XXX not implemented).
+
+Both approaches will raise an exception in case of a return-
+code other than 0 and otherwise return the stdout-output 
+of the child process.
+
+The shell based approach 
+------------------------
+
+You can execute a command via your system shell 
+by doing something like:: 
+
+    out = py.process.cmdexec('ls -v')
+
+However, the ``cmdexec`` approach has a few shortcomings: 
+
+- it relies on the underlying system shell
+- it neccessitates shell-escaping for expressing arguments
+- it does not easily allow to "fix" the binary you want to run.  
+- it only allows to execute executables from the local 
+  filesystem 
+
+
+.. _sysexec: 
+
+local paths have ``sysexec``
+---------------------------- 
+
+The py lib currently offers a stripped down functionality of what
+the new `PEP-324 subprocess module`_ offers.  The main functionality 
+of synchronously executing a system executable has a
+straightforward api:: 
+
+    binsvn.sysexec('ls', 'http://codespeak.net/svn') 
+
+where ``binsvn`` is a path that points to the ``svn`` commandline
+binary. Note that this function would not offer any shell-escaping
+so you really have to pass in separated arguments.  This idea
+fits nicely into `a more general view on path objects`_. 
+
+For a first go, we are just reusing the existing `subprocess
+implementation`_ but don't expose any of its API apart
+from the above "execute()" method. 
+
+.. _`future book`: future.html 
+.. _`PEP-324 subprocess module`: http://www.python.org/peps/pep-0324.html
+.. _`subprocess implementation`: http://www.lysator.liu.se/~astrand/popen5/
+.. _`a more general view on path objects`: future.html#general-path
+
+finding an executable local path
+--------------------------------
+
+Finding an executable is quite different on multiple platforms. 
+Currently, the ``PATH`` environment variable based search on
+unix platforms is supported:: 
+
+    py.path.local.sysfind('svn') 
+
+which returns the first path whose ``basename`` matches ``svn``. 
+In principle, `sysfind` deploys platform specific algorithms
+to perform the search.  On Windows, for example, it may look
+at the registry (XXX). 
+
+To make the story complete, we allow to pass in a second ``checker`` 
+argument that is called for each found executable.  For example, if 
+you have multiple binaries available you may want to select the
+right version:: 
+
+    def mysvn(p):
+        """ check that the given svn binary has version 1.1. """
+        line = p.execute('--version'').readlines()[0]
+        if line.find('version 1.1'): 
+            return p 
+    binsvn = py.path.local.sysfind('svn', checker=mysvn) 
+

Modified: py/dist/py/path/common.py
==============================================================================
--- py/dist/py/path/common.py	(original)
+++ py/dist/py/path/common.py	Wed Oct 20 02:57:43 2004
@@ -303,3 +303,4 @@
         s = self.read()
         # XXX str(self) should show up somewhere in the code's filename
         return py.magic.dyncode.compile2(s)
+

Modified: py/dist/py/path/local/local.py
==============================================================================
--- py/dist/py/path/local/local.py	(original)
+++ py/dist/py/path/local/local.py	Wed Oct 20 02:57:43 2004
@@ -245,7 +245,7 @@
 
     def copy(self, target, archive=False):
         try:
-            assert not archive 
+            assert not archive, "XXX archive-mode not supported" 
             if self.check(file=1):
                 if target.check(dir=1):
                     target = target.join(self.basename)
@@ -304,6 +304,8 @@
 
     def _ensuredirs(self):
         parent = self.dirpath()
+        if parent == self:
+            return self
         if parent.check(dir=0):
             parent._ensuredirs()
         if self.check(dir=0):
@@ -312,8 +314,8 @@
 
     def ensure(self, *args, **kwargs):
         """ ensure that an args-joined path exists (by default as 
-            a file). if you specify a keyword argument 'directory=True'
-            then the path is forced  to be a directory path. 
+            a file). if you specify a keyword argument 'dir=True'
+            then the path is forced to be a directory path. 
         """
         try:
             p = self.join(*args)
@@ -414,6 +416,37 @@
                 pass
         return codeobj
 
+    def sysexec(self, *argv):
+        """ return stdout-put from executing a system child process, 
+            where the self path points to the binary (XXX or script) 
+            to be executed. Note that this process is directly 
+            invoked and not through a system shell. 
+        """
+        from popen5.subprocess import Popen, PIPE
+        proc = Popen([str(self)] + list(argv), stdout=PIPE, stderr=PIPE)
+        ret = proc.wait()
+        if ret != 0:
+            raise py.process.cmdexec.Error(ret, ret, str(self), 
+                                           proc.stdout.read(), 
+                                           proc.stderr.read(),) 
+        return proc.stdout.read() 
+        
+    def sysfind(self, name, checker=None): 
+        """ return a path object found by looking at the systems 
+            underlying PATH specification. (XXX not working 
+            for plain win32 yet, we want transparent c-compilation 
+            through distutils for that. See the future. 
+        """ 
+        for x in py.std.os.environ['PATH'].split(':'):
+            x = py.path.local(x) 
+            if x.check(dir=1) and name in x: 
+                p = x.join(name) 
+                if checker: 
+                    if not checker(p): 
+                        continue 
+                return p 
+        raise py.path.NotFound(self) 
+    sysfind = classmethod(sysfind)
     #"""
     #special class constructors for local filesystem paths
     #"""

Added: py/dist/py/path/local/popen5/__init__.py
==============================================================================
--- (empty file)
+++ py/dist/py/path/local/popen5/__init__.py	Wed Oct 20 02:57:43 2004
@@ -0,0 +1 @@
+#

Copied: py/dist/py/path/local/popen5/test_subprocess.py (from r7054, vendor/popen5/test_subprocess.py)
==============================================================================
--- vendor/popen5/test_subprocess.py	(original)
+++ py/dist/py/path/local/popen5/test_subprocess.py	Wed Oct 20 02:57:43 2004
@@ -1,12 +1,7 @@
-import unittest
-from test import test_support
 import subprocess
 import sys
-import signal
 import os
-import tempfile
-import time
-import re
+import py
 
 mswindows = (sys.platform == "win32")
 
@@ -24,15 +19,16 @@
 # shutdown time.  That frustrates tests trying to check stderr produced
 # from a spawned Python process.
 def remove_stderr_debug_decorations(stderr):
-    return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
+    return py.std.re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
 
-class ProcessTestCase(unittest.TestCase):
+class TestPopen5(py.test.compat.TestCase): 
+    disabled = True
     def mkstemp(self):
         """wrapper for mkstemp, calling mktemp if mkstemp is not available"""
         if hasattr(tempfile, "mkstemp"):
-            return tempfile.mkstemp()
+            return py.std.tempfile.mkstemp()
         else:
-            fname = tempfile.mktemp()
+            fname = py.std.tempfile.mktemp()
             return os.open(fname, os.O_RDWR|os.O_CREAT), fname
 
     #
@@ -97,7 +93,7 @@
 
     def test_stdin_filedes(self):
         # stdin is set to open file descriptor
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         d = tf.fileno()
         os.write(d, "pear")
         os.lseek(d, 0, 0)
@@ -109,7 +105,7 @@
 
     def test_stdin_fileobj(self):
         # stdin is set to open file object
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         tf.write("pear")
         tf.seek(0)
         p = subprocess.Popen([sys.executable, "-c",
@@ -127,7 +123,7 @@
 
     def test_stdout_filedes(self):
         # stdout is set to open file descriptor
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         d = tf.fileno()
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys; sys.stdout.write("orange")'],
@@ -138,7 +134,7 @@
 
     def test_stdout_fileobj(self):
         # stdout is set to open file object
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys; sys.stdout.write("orange")'],
                          stdout=tf)
@@ -156,7 +152,7 @@
 
     def test_stderr_filedes(self):
         # stderr is set to open file descriptor
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         d = tf.fileno()
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys; sys.stderr.write("strawberry")'],
@@ -168,7 +164,7 @@
 
     def test_stderr_fileobj(self):
         # stderr is set to open file object
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys; sys.stderr.write("strawberry")'],
                          stderr=tf)
@@ -192,7 +188,7 @@
 
     def test_stdout_stderr_file(self):
         # capture stdout and stderr to the same open file
-        tf = tempfile.TemporaryFile()
+        tf = py.std.tempfile.TemporaryFile()
         p = subprocess.Popen([sys.executable, "-c",
                           'import sys;' \
                           'sys.stdout.write("apple");' \
@@ -371,7 +367,7 @@
                           "-c", "import time; time.sleep(1)"])
         count = 0
         while p.poll() is None:
-            time.sleep(0.1)
+            py.std.time.sleep(0.1)
             count += 1
         # We expect that the poll loop probably went around about 10 times,
         # but, based on system scheduling we can't control, it's possible
@@ -410,7 +406,7 @@
             p = subprocess.Popen([sys.executable,
                                   "-c", "import os; os.abort()"])
             p.wait()
-            self.assertEqual(-p.returncode, signal.SIGABRT)
+            self.assertEqual(-p.returncode, py.std.signal.SIGABRT)
 
         def test_preexec(self):
             # preexec function
@@ -548,8 +544,8 @@
             self.assertEqual(rc, 47)
 
 
-def test_main():
-    test_support.run_unittest(ProcessTestCase)
-
-if __name__ == "__main__":
-    test_main()
+#def test_main():
+#    test_support.run_unittest(ProcessTestCase)
+#
+#if __name__ == "__main__":
+#    test_main()

Modified: py/dist/py/path/local/posix.py
==============================================================================
--- py/dist/py/path/local/posix.py	(original)
+++ py/dist/py/path/local/posix.py	Wed Oct 20 02:57:43 2004
@@ -73,7 +73,7 @@
             self._except(sys.exc_info())
 
     def mklinkto(self, oldname): 
-        """ hard link to an old name. """ 
+        """ posix style hard link to another name. """ 
         try:
             os.link(str(oldname), str(self)) 
         except:

Modified: py/dist/py/path/local/test_local.py
==============================================================================
--- py/dist/py/path/local/test_local.py	(original)
+++ py/dist/py/path/local/test_local.py	Wed Oct 20 02:57:43 2004
@@ -1,25 +1,31 @@
-import sys, os
-from py.test import raises, config 
+import py
 from py.path import local, checker
 from py.__impl__.path.test.fscommon import CommonFSTests, setuptestfs 
 
-class TestLocalPath(CommonFSTests):
+class LocalSetup:
     def setup_class(cls):
-        cls.root = config.tmpdir / 'TestLocalPath'
+        cls.root = py.test.config.tmpdir / 'TestLocalPath'
         cls.root.ensure(dir=1)
         setuptestfs(cls.root)
+
+    def setup_method(self, method):
+        self.tmpdir = self.root.ensure('tmpdir', dir=1)
+
+    def teardown_method(self, method):
+        self.tmpdir.remove(rec=1)
         
+class TestLocalPath(LocalSetup, CommonFSTests):
     def test_initialize_curdir(self):
-        assert str(local()) == os.getcwd()
+        assert str(local()) == py.std.os.getcwd()
 
     def test_initialize_reldir(self):
-        curdir = os.curdir
+        curdir = py.std.os.curdir
         try:
-            os.chdir(str(self.root))
+            py.std.os.chdir(str(self.root))
             p = local('samplefile')
             assert p.check()
         finally:
-            os.chdir(curdir)
+            py.std.os.chdir(curdir)
 
     def test_eq_with_strings(self):
         path1 = self.root.join('sampledir')
@@ -34,7 +40,7 @@
         import tempfile
         try:
             fd, name = tempfile.mkstemp()
-            f = os.fdopen(fd)
+            f = py.std.os.fdopen(fd)
         except AttributeError:
             name = tempfile.mktemp()
             f = open(name, 'w+')
@@ -47,14 +53,14 @@
             assert d == dnew
         finally:
             f.close()
-            os.remove(name)
+            py.std.os.remove(name)
 
     def test_setmtime(self):
         import tempfile
         import time
         try:
             fd, name = tempfile.mkstemp()
-            os.close(fd)
+            py.std.os.close(fd)
         except AttributeError:
             name = tempfile.mktemp()
             open(name, 'w').close()
@@ -67,7 +73,7 @@
             path.setmtime()
             assert path.mtime() != mtime
         finally:
-            os.remove(name)
+            py.std.os.remove(name)
 
     def test_normpath(self):
         new1 = self.root.join("/otherdir")
@@ -90,84 +96,104 @@
         finally:
             d.remove(rec=1)
 
-    def test_ensure_filepath_withdir(self):
-        tmpdir = local.mkdtemp()
-        try:
-            newfile = tmpdir.join('test1','test2')
-            newfile.ensure()
-            assert newfile.check(file=1)
-        finally:
-            tmpdir.remove(rec=1)
-
-    def test_ensure_filepath_withoutdir(self):
-        tmpdir = local.mkdtemp()
-        try:
-            newfile = tmpdir.join('test1')
-            t = newfile.ensure()
-            assert t == newfile
-            assert newfile.check(file=1)
-        finally:
-            tmpdir.remove(rec=1)
-
-    def test_ensure_dirpath(self):
-        tmpdir = local.mkdtemp()
-        try:
-            newfile = tmpdir.join('test1','test2')
-            t = newfile.ensure(dir=1)
-            assert t == newfile
-            assert newfile.check(dir=1)
-        finally:
-            tmpdir.remove(rec=1)
-
     def test_mkdir(self):
-        tmpdir = local.mkdtemp()
-        try:
-            new = tmpdir.join('test1')
-            new.mkdir()
-            assert new.check(dir=1)
-
-            new = tmpdir.mkdir('test2')
-            assert new.check(dir=1)
-            assert tmpdir.join('test2') == new
-        finally:
-            tmpdir.remove(rec=1)
+        tmpdir = self.tmpdir 
+        new = tmpdir.join('test1')
+        new.mkdir()
+        assert new.check(dir=1)
+
+        new = tmpdir.mkdir('test2')
+        assert new.check(dir=1)
+        assert tmpdir.join('test2') == new
 
     def test_chdir(self):
-        import os
+        tmpdir = self.tmpdir 
         old = local() 
-        tmpdir = local.mkdtemp()
         try:
             res = tmpdir.chdir()
             assert str(res) == str(old)
-            assert os.getcwd() == str(tmpdir)
+            assert py.std.os.getcwd() == str(tmpdir)
         finally:
             old.chdir()
-            tmpdir.remove(rec=1)
 
+    def test_ensure_filepath_withdir(self):
+        tmpdir = self.tmpdir 
+        newfile = tmpdir.join('test1','test2')
+        newfile.ensure()
+        assert newfile.check(file=1)
 
-class TestMisc:
-    root = local(TestLocalPath.root)
+    def test_ensure_filepath_withoutdir(self):
+        tmpdir = self.tmpdir 
+        newfile = tmpdir.join('test1')
+        t = newfile.ensure()
+        assert t == newfile
+        assert newfile.check(file=1)
+
+    def test_ensure_dirpath(self):
+        tmpdir = self.tmpdir 
+        newfile = tmpdir.join('test1','test2')
+        t = newfile.ensure(dir=1)
+        assert t == newfile
+        assert newfile.check(dir=1)
+
+class TestExecution(LocalSetup):
+    disabled = py.std.sys.platform == 'win32' 
+
+    def test_sysfind(self):
+        x = py.path.local.sysfind('ls')
+        assert x.check(file=1) 
+        py.test.raises(py.path.NotFound, """
+            py.path.local.sysfind('jaksdkasldqwe')
+        """) 
+
+    def test_sysfind_multiple(self):
+        dir = py.test.config.tmpdir.ensure('sysfind', dir=1) 
+        env = py.std.os.environ
+        oldpath = env['PATH'] 
+        try: 
+            env['PATH'] += ":%s:%s" % (dir.ensure('a'), 
+                                       dir.join('b')) 
+            dir.ensure('b', 'a') 
+            checker = lambda x: x.dirpath().basename == 'b'
+            x = py.path.local.sysfind('a', checker=checker)
+            assert x.basename == 'a'
+            assert x.dirpath().basename == 'b' 
+            checker = lambda x: None 
+            py.test.raises(py.path.NotFound, """ 
+                 py.path.local.sysfind('a', checker=checker)
+            """) 
+        finally:
+            env['PATH'] = oldpath 
+            #dir.remove() 
+
+    def test_sysexec(self):
+        x = py.path.local.sysfind('ls')
+        out = x.sysexec() 
+        for x in py.path.local():
+            assert out.find(x.basename) != -1 
+
+    def test_sysexec_failing(self):
+        x = py.path.local.sysfind('ls') 
+        py.test.raises(py.process.cmdexec.Error, """
+            x.sysexec('aksjdkasjd')
+        """)
 
     def test_make_numbered_dir(self):
-        root = local.mkdtemp()
-        try:
-            for i in range(10):
-                numdir = local.make_numbered_dir(root, 'base.', keep=2)
-                assert numdir.check()
-                assert numdir.get('basename') == 'base.%d' %i
-                if i>=1:
-                    assert numdir.new(ext=str(i-1)).check()
-                if i>=2:
-                    assert numdir.new(ext=str(i-2)).check()
-                if i>=3:
-                    assert not numdir.new(ext=str(i-3)).check()
-        finally:
-            #print "root was", root
-            root.remove(rec=1)
+        root = self.tmpdir 
+        for i in range(10):
+            numdir = local.make_numbered_dir(root, 'base.', keep=2)
+            assert numdir.check()
+            assert numdir.get('basename') == 'base.%d' %i
+            if i>=1:
+                assert numdir.new(ext=str(i-1)).check()
+            if i>=2:
+                assert numdir.new(ext=str(i-2)).check()
+            if i>=3:
+                assert not numdir.new(ext=str(i-3)).check()
 
     def test_error_preservation(self):
-        raises (OSError, self.root.join('qwoeqiwe').mtime)
-        raises (IOError, self.root.join('qwoeqiwe').read)
+        py.test.raises (OSError, self.root.join('qwoeqiwe').mtime)
+        py.test.raises (IOError, self.root.join('qwoeqiwe').read)
 
     #def test_parentdirmatch(self):
     #    local.parentdirmatch('std', startmodule=__name__)

Modified: py/dist/py/path/svn/svntestbase.py
==============================================================================
--- py/dist/py/path/svn/svntestbase.py	(original)
+++ py/dist/py/path/svn/svntestbase.py	Wed Oct 20 02:57:43 2004
@@ -7,9 +7,10 @@
 
     def setup_method(self, meth):
         bn = meth.func_name 
-        if bn.startswith('test_remove') or bn.startswith('test_move'):
-            raise py.test.Skipped(msg=
-                "tests for (re)move require better svn state management")
+        for x in 'test_remove', 'test_move': 
+            if bn.startswith(x): 
+                raise py.test.Skipped(msg=
+                "tests for modifying svn needs better test state management")
 
     def test_propget(self):
         url = self.root.join("samplefile")

Modified: py/dist/py/path/test/common.py
==============================================================================
--- py/dist/py/path/test/common.py	(original)
+++ py/dist/py/path/test/common.py	Wed Oct 20 02:57:43 2004
@@ -199,4 +199,3 @@
         for name in dir(local.Checkers):
             if name[0] != '_':
                 assert name in doc 
-

Modified: py/dist/py/path/test/fscommon.py
==============================================================================
--- py/dist/py/path/test/fscommon.py	(original)
+++ py/dist/py/path/test/fscommon.py	Wed Oct 20 02:57:43 2004
@@ -197,3 +197,4 @@
         # because this would mean confusion with respect to
         # py.path.extpy
         assert not hasattr(self.root, 'resolve')
+

Modified: py/dist/py/test/raises.py
==============================================================================
--- py/dist/py/test/raises.py	(original)
+++ py/dist/py/test/raises.py	Wed Oct 20 02:57:43 2004
@@ -1,5 +1,7 @@
 import sys
-from py import test, magic
+import py 
+
+from py.__impl__ import test 
 
 def raises(ExpectedException, *args, **kwargs):
     """ raise AssertionError, if target code does not raise the expected 
@@ -14,7 +16,7 @@
         loc.update(kwargs)
         #print "raises frame scope: %r" % frame.f_locals
         try:
-            eval(magic.dyncode.compile2(expr), frame.f_globals, loc) 
+            eval(py.magic.dyncode.compile2(expr), frame.f_globals, loc) 
             # XXX didn'T mean f_globals == f_locals something special?
             #     this is destroyed here ... 
         except ExpectedException:

Modified: py/dist/py/test/run.py
==============================================================================
--- py/dist/py/test/run.py	(original)
+++ py/dist/py/test/run.py	Wed Oct 20 02:57:43 2004
@@ -113,6 +113,7 @@
             self._instance = method.im_class() 
         method = method.__get__(self._instance, method.im_class) 
         if hasattr(self._instance, 'setup_method'):
+            print "execting setup", self._instance.setup_method
             self._instance.setup_method(method) 
         return (method, getattr(self._instance, 'teardown_method', None))
 



More information about the pytest-commit mailing list