<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 12/06/11 20:55, Hans Sebastian wrote:
<blockquote
cite="mid:CAMH0=P9LVY0UBCh2hH0YKA6UHmz7yDZMbr=H-z2vhHo4h63pdg@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
Hi all,<br>
<br>
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.</blockquote>
<br>
<br>
<blockquote
cite="mid:CAMH0=P9LVY0UBCh2hH0YKA6UHmz7yDZMbr=H-z2vhHo4h63pdg@mail.gmail.com"
type="cite"><font face="courier new,monospace">
<br>
def fileno(self):<br>
> raise ValueError("redirected Stdin is pseudofile, has
no fileno()")<br>
E ValueError: redirected Stdin is pseudofile, has no
fileno()<br>
</font></blockquote>
<br>
<br>
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.<br>
<br>
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 <a class="moz-txt-link-freetext" href="http://pytest.org/latest/capture.html">http://pytest.org/latest/capture.html</a> .<br>
<br>
Mark S.<br>
<br>
</body>
</html>