[py-svn] py-trunk commit 717f09c82287: make looponfailing a bit more robust against relative imports and changed directories - needs more work, probably.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Dec 29 18:41:50 CET 2009


# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1262108484 -3600
# Node ID 717f09c82287ac415d60579e45c6cafc5c99875d
# Parent a6a865e1e25d692b8df70d656e0067b400015f13
make looponfailing a bit more robust against relative imports and changed directories - needs more work, probably.

--- a/py/impl/test/looponfail/remote.py
+++ b/py/impl/test/looponfail/remote.py
@@ -62,22 +62,22 @@ class RemoteControl(object):
         if hasattr(self, 'gateway'):
             raise ValueError("already have gateway %r" % self.gateway)
         self.trace("setting up slave session")
-        old = self.config.topdir.chdir()
-        try:
-            self.gateway = self.initgateway()
-        finally:
-            old.chdir()
-        channel = self.gateway.remote_exec(source="""
+        self.gateway = self.initgateway()
+        channel = self.gateway.remote_exec("""
+            import os
             from py.impl.test.dist.mypickle import PickleChannel
             from py.impl.test.looponfail.remote import slave_runsession
+            chdir = channel.receive()
             outchannel = channel.gateway.newchannel()
             channel.send(outchannel)
             channel = PickleChannel(channel)
+            os.chdir(chdir) # unpickling config uses cwd as topdir
             config, fullwidth, hasmarkup = channel.receive()
             import sys
             sys.stdout = sys.stderr = outchannel.makefile('w')
             slave_runsession(channel, config, fullwidth, hasmarkup) 
         """)
+        channel.send(str(self.config.topdir))
         remote_outchannel = channel.receive()
         def write(s):
             out._file.write(s)

--- a/testing/pytest/test_config.py
+++ b/testing/pytest/test_config.py
@@ -16,7 +16,6 @@ class TestConfigCmdlineParsing:
                         help='t value'),
                 )
             """)
-        testdir.chdir() 
         config = testdir.reparseconfig(['-G', '17'])
         assert config.option.gdest == 17 
 
@@ -46,19 +45,6 @@ class TestConfigCmdlineParsing:
         config = testdir.parseconfig()
         assert config.option.verbose 
 
-    def test_config_cmdline_options_only_lowercase(self, testdir): 
-        testdir.makepyfile(conftest="""
-            import py
-            Option = py.test.config.Option
-            options = py.test.config.addoptions("testing group", 
-                Option('-g', '--glong', action="store", default=42,
-                       type="int", dest="gdest", help="g value."), 
-                )
-        """)
-        py.test.raises(ValueError, """
-            testdir.reparseconfig(['-g', '17'])
-        """)
-
     def test_parsing_again_fails(self, testdir):
         config = testdir.reparseconfig([testdir.tmpdir])
         py.test.raises(AssertionError, "config.parse([])")



More information about the pytest-commit mailing list