title: How to mock sys.stdout (err, in) for subprocess.call
body: <p>I want to capture and analyze output for a function which do this:</p>
  
  <p>subprocess.call(args, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stderr)</p>
  
  <p>When I run this code without any mocks under py.test I get error: <code>ValueError: redirected Stdin is pseudofile, has no fileno()</code></p>
  
  <p>When I patch sys.stdin (and others) with mock I get the same error.</p>
  
  <p>When I patch sys.stdin with <code>mock.mock_open()</code> I get error: <code>AttributeError: Mock object has no attribute 'write'</code></p>
  
  <p>When I patch sys.stdin with <code>mock.mock_open()('name', 'r')</code> I get initial  error: <code>ValueError: redirected Stdin is pseudofile, has no fileno()</code></p>
  
  <p>Is any way to pass some kind of mock object as stdin/out for subprocess?</p>
  
  <p>I want something like this:</p>
  
  <pre><code>mocked = (put something here)
  subprocess_call('ls', stdin=mocked, stdout=mocked, stderr=mocked)
  </code></pre>
  
  <p>Which should work when run under py.test.</p>
  
  <p>Thanks.</p>