escribiendo una función pytest para verificar la salida en la consola (stdout) en python?

Este enlace proporciona una descripción de cómo usar pytest para capturar salidas de consola. Probé este siguiente código simple, pero me sale un error.

import sys
import pytest
def f(name):
    print "hello "+ name

def test_add(capsys):
    f("Tom")
    out,err=capsys.readouterr()
    assert out=="hello Tom"


test_add(sys.stdout)

Salida:

python test_pytest.py 
hello Tom
Traceback (most recent call last):
  File "test_pytest.py", line 12, in <module>
    test_add(sys.stdout)
  File "test_pytest.py", line 8, in test_add
    out,err=capsys.readouterr()
AttributeError: 'file' object has no attribute 'readouterr'

¿Qué está mal y qué solución se necesita? gracias

EDITAR: Según el comentario, he cambiadocapfd, pero sigo teniendo el mismo error

import sys
import pytest
def f(name):
    print "hello "+ name

def test_add(capfd):
    f("Tom")
    out,err=capfd.readouterr()
    assert out=="hello Tom"


test_add(sys.stdout)

Respuestas a la pregunta(2)

Su respuesta a la pregunta