[TIP] problem running fabric commands with py.test

Mark Sienkiewicz sienkiew at stsci.edu
Wed Dec 7 12:14:03 PST 2011


On 12/06/11 20:55, Hans Sebastian wrote:
> Hi all,
>
> I am trying to execute a remote command using fabric in my test run by py.test. Fabric is a library for using SSH and I myself is quite new to it and just want to start using it. The problem is when i run it with py.test I am getting an error, but not when invoking with python.


>
>     def fileno(self):
> >       raise ValueError("redirected Stdin is pseudofile, has no fileno()")
> E       ValueError: redirected Stdin is pseudofile, has no fileno()


py.test is replacing sys.stdin and sys.stdout with "file-like objects", but those objects do not have any real file descriptors.  This fileno() can't possibly return a correct value (there is no file descriptor), so it raises an exception.  The logic is that automated tests are not interactive, so we expect them to not read from stdin.

Your program is trying to do something directly with the file descriptor for stdin, so you can't have your test system preventing access.  You might try "pytest -s" to make it not mess with stdin/stdout.  There is a brief discussion of capturing stdin/stdout at http://pytest.org/latest/capture.html .

Mark S.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20111207/c86b7955/attachment.htm>


More information about the testing-in-python mailing list