Ale*_*din 5 python unicode ascii pytest
如果我编写了一个简单的测试(将失败)来检查UTF-8字符串(请参见下面的示例)并使用py.test启动它,则带有错误的输出将使用ASCII编码\x。
测试:
#-*- coding: utf-8 -*-
def test():
assert "????" == "????1"
Run Code Online (Sandbox Code Playgroud)
输出:
def test():
> assert "????" == "????1"
E assert '\xd1\x82\xd0...1\x81\xd1\x82' == '\xd1\x82\xd0\...\x81\xd1\x821'
E - ????
E + ????1
E ? +
test.py:3: AssertionError
Run Code Online (Sandbox Code Playgroud)
问题是:有没有办法使输出正常(使用py.test)?我的意思是没有\x,就像一个E assert '????' == '????1'。