Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 如何在Pytest参数化ID中显示非ascii字符_Python_Pycharm_Pytest - Fatal编程技术网

Python 如何在Pytest参数化ID中显示非ascii字符

Python 如何在Pytest参数化ID中显示非ascii字符,python,pycharm,pytest,Python,Pycharm,Pytest,这是我的测试脚本: @pytest.mark.parametrize('data', [0, 1], ids=['有效', '无效']) def test_a(data): assert 1 但是每个id的名称在Pycharm和Terminal中都被转义: 那么,如何解决这个问题呢?自2019年4月起,pytest通过pytest.ini中的以下配置设置来支持此功能,或者: 在这种配置下,问题中的示例按照设计工作,没有任何更改 此设置已记录在案 注意:顾名思义,社区支持可能无法解决

这是我的测试脚本:

@pytest.mark.parametrize('data', [0, 1], ids=['有效', '无效'])
def test_a(data):
    assert 1
但是每个id的名称在Pycharm和Terminal中都被转义:


那么,如何解决这个问题呢?

自2019年4月起,pytest通过
pytest.ini
中的以下配置设置来支持此功能,或者:

在这种配置下,问题中的示例按照设计工作,没有任何更改

此设置已记录在案

注意:顾名思义,社区支持可能无法解决在此配置中运行时出现的问题,并且可能会导致Windows出现问题,请小心使用


该更改通过合并而成,可以找到一个有点晦涩难懂的名称(以及此设置可能出现的问题)的讨论。

print a.decode('utf-8')。encode('gb2312')不知道这是否是正确的编码。这里的类似问题不是同一个故事
pytest
转义参数化ID,无法重新配置。有关详细信息,请参阅。
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True