【问题标题】:utf-8 pytest output converted to ascii with \x使用 \x 将 utf-8 pytest 输出转换为 ascii
【发布时间】:2013-06-16 08:04:05
【问题描述】:

如果我编写一个简单的测试(这将失败)来检查 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

问题是:有没有办法使输出正常(使用 py.test)?我的意思是没有\x,比如E assert 'тест' == 'тест1'

【问题讨论】:

  • 嗯,听起来你应该提交一个错误。从输出看,在断言重写和 python 的 difflib 中有一个错误。
  • 有什么消息吗?解决方案?不能谷歌这个:)
  • @spacediver 我为 pytest 创建了一个bug 并已解决。

标签: python unicode ascii pytest


【解决方案1】:

【讨论】:

    猜你喜欢
    • 2019-10-31
    • 2012-08-04
    • 2011-06-26
    • 2011-01-16
    • 2012-10-29
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 2017-11-20
    相关资源
    最近更新 更多