Hi Simon, i finally got around to look at your plugin ...
On Thu, Oct 29, 2009 at 17:42 +1100, Simon wrote: > On 28/10/2009, at 19:44 , holger krekel holger-at-merlinux.eu |py-dev + > execnet-dev| wrote: > >>> Hi Holger, >>> >>> I started looking into this a bit but ran into a problem when I >>> started to probe the py.io module. >>> >>> I tried running the py.io examples on the website >>> <http://codespeak.net/py/dist/io.html >>>> but when I run the py.io.StdCaptureFD example, python dies on the >>> second line: >>> >>> stak...@okum:~$ python >>> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41) >>> [GCC 4.3.3] on linux2 >>> Type "help", "copyright", "credits" or "license" for more >>> information. >>> History restored: /auto/home/stakita/.pyhistory, Max Length: 500 >>>>>> import py, sys >>>>>> capture = py.io.StdCaptureFD() >> >> The redirect here happens for stdout, stderr and stdin is put to >> /dev/zero on the file descriptor level ... >> >>> stak...@okum:~$ >> >> ... so the python interpreter immediately gets an EOL on stdin and >> dies. > > So does this mean that the example is a bit broken then? yes, i fixed it in trunk. >>> My guess is that an exception is being thrown, but the captured >>> sys.stderr descriptor is not passing any meaningful traceback. >> >> you can call py.io.StdCaptureFD(err=True, in_=False, >> out=False) and should be able to play with writing to stderr. >> >>> I tried wrapping the call in try/except, but that didn't seem to >>> help. >>> On the positive side, the problem appears to be quite reproducible. >>> >>> Any ideas on what is going on here? >> >> just anoter recommendation. Maybe it is easiest for you to implement >> a "--iocapturelog=filename" option and see to send output to >> it from the pytest_capture plugin on the py-trunk repository. >> You can start experimenting by copying the pytest_capture.py >> file somewhere into your import path and modifying it. Your >> local version will override the builtin one. >> >> HTH, >> holger > > Thanks for the suggestion, and here is a first pass. Attached is a > modified version of pytest_capture.py from the 1.0.2 release. > > In this file, I just push the options into the CaptureManager so that > the command line args are available. This does mean that the config file > options stuff is not hooked up, but at least it works from the command > line at the moment. just using "config.getvalue()" should be fine. "py.test --help-config" then shows the derived ENV/conftest.py settings, btw. > Additional plugin command line options are: > --log-file <filename> > When used with the two capture options ('fd' and 'sys') this > will enable pushing the stdout and stderr writes to the specified file. > --append-log > This allows appending to the file as opposed to the default > clobber behaviour. > > Does this fit with your model of how the plugin should be structured? roughly, yes :) some small comments: * the "append-log" option i'd rather encode as "+logfilename" for the capture-file option (goal is to minimize number of cmdline args) just one --capture-file option makes sense * "self.logfd" is actually a file object, not a file descriptor, so better use "self.capture_file" or so. * your code is not Python3 compatible I'd like to include your changes ... could you rework your patch by checking out http://bitbucket.org/hpk42/py-trunk and modifying _py/test/plugin/pytest_capture.py and running and adding tests here: testing/pytest/plugin/test_pytest_capture.py ? FYI on linux/OSX you can do alias py.test='python /path/to/checkout/bin/py.test' alias py.test3='python3 /path/to/checkout/bin/py.test' to easily have the two main py.test runs available ... adding a py.testjython alias is a bonus :) In any case, feel free to ask more questions, also on #pylib freenode. cheers, holger _______________________________________________ py-dev mailing list py-dev@codespeak.net http://codespeak.net/mailman/listinfo/py-dev