def fake_print(*args, **kwargs):
    sep = kwargs.pop('sep', ' ')
    end = kwargs.pop('end', '\n')
    file = kwargs.pop('file', sys.stdout)
    if (file in (oldout, olderr, sys.stdout, sys.stderr)):
        try:
            sys.stdout.write((sep.join(args) + end))
        except UnicodeEncodeError as exc:
            lgr.error("Failed to write to mocked stdout, got %s, continue as it didn't happen", exc)
    else:
        oldprint(*args, sep=sep, end=end, file=file)
def fake_print(*args, **kwargs):
    sep = kwargs.pop('sep', ' ')
    end = kwargs.pop('end', '\n')
    file = kwargs.pop('file', sys.stdout)
    if (file in (oldout, olderr, sys.stdout, sys.stderr)):
        try:
            sys.stdout.write((sep.join(args) + end))
        except UnicodeEncodeError as exc:
            lgr.error("Failed to write to mocked stdout, got %s, continue as it didn't happen", exc)
    else:
        oldprint(*args, sep=sep, end=end, file=file)