Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python utf-8 pytest输出用\x转换为ascii_Python_Unicode_Ascii_Pytest - Fatal编程技术网

Python utf-8 pytest输出用\x转换为ascii

Python utf-8 pytest输出用\x转换为ascii,python,unicode,ascii,pytest,Python,Unicode,Ascii,Pytest,如果我编写一个简单的测试(将失败)来检查UTF-8字符串(参见下面的示例),并使用py.test启动它,那么带有错误的输出将使用\x进行ascii编码 测试: #-*- coding: utf-8 -*- def test(): assert "тест" == "тест1" def test(): > assert "тест" == "тест1" E assert '\xd1\x82\xd0...1\x81\xd1\x82' == '\xd1\x8

如果我编写一个简单的测试(将失败)来检查UTF-8字符串(参见下面的示例),并使用py.test启动它,那么带有错误的输出将使用
\x
进行ascii编码

测试:

#-*- coding: utf-8 -*-
def test():
    assert "тест" == "тест1"
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
输出:

#-*- coding: utf-8 -*-
def test():
    assert "тест" == "тест1"
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

问题是:有没有办法使输出正常(使用py.test)?我的意思是,如果没有
\x
,比如
E断言'etcöС'=='etcöСτ1'
,那么,这是一个bug,它已经修复了:。

嗯,听起来你应该提交一个bug。从输出的外观来看,断言重写和python的difflib中有一个bug。有什么消息吗?解决?无法用谷歌搜索此:)@spacediver我为pytest创建了一个测试,该测试已解决。