如何在 Pytest 参数化 id 中显示非 ascii 字符
How can I display non-ascii characters in Pytest parametrize ids
这是我的测试脚本:
@pytest.mark.parametrize('data', [0, 1], ids=['有效', '无效'])
def test_a(data):
assert 1
但每个 id 的名称在 Pycharm 和终端中都被转义了:
那么,如何解决这个问题?
截至 2019 年 4 月,pytest 通过 pytest.ini
或 other configuration 中的以下配置设置支持此功能:
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
使用该配置,问题中的示例无需更改即可按设计工作。
此设置记录在案 here。
注意: 顾名思义,对于 运行 在此配置中引起的问题,社区支持可能不可用,并且可能会导致 [=27= 上的问题],慎用
更改已通过 pull request no. 4995, and a discussion of the somewhat esoteric-née-discouraging name (and possible issues that can occur with this setting) can be found in the linked issue (no. 2482) 合并。
这是我的测试脚本:
@pytest.mark.parametrize('data', [0, 1], ids=['有效', '无效'])
def test_a(data):
assert 1
但每个 id 的名称在 Pycharm 和终端中都被转义了:
那么,如何解决这个问题?
截至 2019 年 4 月,pytest 通过 pytest.ini
或 other configuration 中的以下配置设置支持此功能:
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = True
使用该配置,问题中的示例无需更改即可按设计工作。
此设置记录在案 here。
注意: 顾名思义,对于 运行 在此配置中引起的问题,社区支持可能不可用,并且可能会导致 [=27= 上的问题],慎用
更改已通过 pull request no. 4995, and a discussion of the somewhat esoteric-née-discouraging name (and possible issues that can occur with this setting) can be found in the linked issue (no. 2482) 合并。