human
Complete this python program:
def _fix_spoof_python2(runner, encoding):
assistant
#Here is the Python code you requested.

    """Installs a "SpoofOut" into the given DebugRunner so it properly deals with unicode output. This
    should patch only doctests for text files because they don\t have a way to declare their
    encoding. Doctests in docstrings from Python modules don\t have the same problem given that
    Python already decoded the strings.
    This fixes the problem related in issue #2434.
    """
    from _pytest.compat import _PY2
    if (not _PY2):
        return
    from doctest import _SpoofOut
    class UnicodeSpoof(_SpoofOut, ):
        def getvalue(self):
            result = _SpoofOut.getvalue(self)
            if encoding:
                result = result.decode(encoding)
            return result
    runner._fakeout = UnicodeSpoof()