示例#1
0
文件: test_api.py 项目: lazka/senf
def test_print_strict_strio():
    f = StringIO()

    real_write = f.write

    def strict_write(data):
        if not isinstance(data, text_type):
            raise TypeError
        real_write(data.encode("utf-8").decode("utf-8"))

    f.write = strict_write

    print_(b"\xff\xfe".decode(_encoding, "surrogateescape"), file=f)
    assert f.getvalue() == u"\ufffd\ufffd\n"
示例#2
0
文件: test_hypo.py 项目: lazka/senf
def test_print_bytes(objects, sep, end, flush):
    h = StringIO()
    print_(*objects, sep=sep, end=end, flush=flush, file=h)
    h.getvalue()
示例#3
0
文件: test_api.py 项目: lazka/senf
def test_print_py3_stringio():
    if os.name != "nt" and PY3:
        f = StringIO()
        print_(b"\xff\xfe", file=f)
        assert f.getvalue() == \
            b"\xff\xfe\n".decode(_encoding, "surrogateescape")