且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Python:在 doctests 中接受 unicode 字符串作为常规字符串

更新时间:2023-02-18 19:23:35

您可以设置 ALLOW_UNICODE 标志(全局或每个测试),请参阅 pytest 文档 了解详情.

You can set the ALLOW_UNICODE flag (either globally or per test), see the pytest docs for details.

示例:

[pytest]
doctest_optionflags = ALLOW_UNICODE

# content of example.rst
>>> get_unicode_greeting()  # doctest: +ALLOW_UNICODE
'Hello'