Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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是否在测试名称中支持unicode?_Python_Pytest - Fatal编程技术网

Python pytest是否在测试名称中支持unicode?

Python pytest是否在测试名称中支持unicode?,python,pytest,Python,Pytest,这是我的测试样本(test_time.py): 以下是pytest输出: ============================================================================== FAILURES ============================================================================== ______________________________________________

这是我的测试样本(test_time.py):

以下是pytest输出:

============================================================================== FAILURES ==============================================================================
_________________________________________________________________ test_timedistance_v1[\u4e2d\u6587] _________________________________________________________________

a = datetime.datetime(2001, 12, 12, 0, 0), b = datetime.datetime(2001, 12, 11, 0, 0), expected = datetime.timedelta(1)

    @pytest.mark.parametrize("a,b,expected", testdata, ids=[u"中文", u"English"])
    def test_timedistance_v1(a, b, expected):
        diff = a - b
>       assert diff != expected
E       assert datetime.timedelta(1) != datetime.timedelta(1)

test_time.py:15: AssertionError
___________________________________________________________________ test_timedistance_v1[English] ____________________________________________________________________

a = datetime.datetime(2001, 12, 11, 0, 0), b = datetime.datetime(2001, 12, 12, 0, 0), expected = datetime.timedelta(-1)

    @pytest.mark.parametrize("a,b,expected", testdata, ids=[u"中文", u"English"])
    def test_timedistance_v1(a, b, expected):
        diff = a - b
>       assert diff != expected
E       assert datetime.timedelta(-1) != datetime.timedelta(-1)

test_time.py:15: AssertionError
====================================================================== 2 failed in 0.05 seconds ======================================================================
对于输出中的第二行,测试名称是“test_timedistance_v1[\u4e2d\u6587]”,我希望它是“test_timedistance_v1”[中文]", py.test支持它吗?
(我的pytest版本是3.1.2,OS:macOS 10.12.5)

它不取决于pytest,而是取决于您的计算机区域设置

这里是测试的跟踪日志(LC_ALL=“en_US.UTF-8”):

LC_ALL=“fr_fr.iso8859-1”

================================ test session starts ================================
platform linux -- Python 3.5.3, pytest-2.9.2, py-1.4.34, pluggy-0.3.1
rootdir: /home/..../tmp, inifile: 
collected 2 items 

pytest_chin.py FF

===================================== FAILURES ======================================
_____________________________ test_timedistance_v1[中文] ______________________________
...
================================ test session starts ================================
platform linux -- Python 3.5.3, pytest-2.9.2, py-1.4.34, pluggy-0.3.1
rootdir: /home/gustavi/tmp, inifile: 
collected 2 items 

pytest_chin.py FF

===================================== FAILURES ======================================
\x1b[1m\x1b[31m_____________________________ test_timedistance_v1[\u4e2d\u6587] ______________________________\x1b[0m
...

在OS X上设置您的区域设置的有用链接。

刚刚找到,看起来还不受支持。我已尝试将LC_ALL&LANG导出到en_US.UTF-8 | zh_CN | zh_CN.UTF-8 | C.UTF-8,这一切都不起作用。可能它只在Linux平台上起作用。
================================ test session starts ================================
platform linux -- Python 3.5.3, pytest-2.9.2, py-1.4.34, pluggy-0.3.1
rootdir: /home/gustavi/tmp, inifile: 
collected 2 items 

pytest_chin.py FF

===================================== FAILURES ======================================
\x1b[1m\x1b[31m_____________________________ test_timedistance_v1[\u4e2d\u6587] ______________________________\x1b[0m
...