[Python] How to display valid Chinese Characters in pytest's pytest.mark.parametrize?

Discussão em 'Python' iniciado por Stack, Maio 30, 2025.

  1. Stack

    Stack Membro Participativo

    import pytest
    import nlu

    @pytest.mark.parametrize("text", ["我喜欢美妆里面的碧唇果酸面膜!"])
    def test_tokenizer_sentence(text):
    tokens = nlu.nlp(text)
    print (tokens)
    assert len(tokens['tokens']['words']) == 9


    From the unit pytest above, the output is below if I run it:

    test_tokenizer.py::test_tokenizer_sentence[\u6211\u559c\u6b22\u7f8e\u5986\u91cc\u9762\u7684\u78a7\u5507\u679c\u9178\u9762\u819c!] PASSED [100%]{'text': '我喜欢美妆里面的碧唇果酸面膜!', 'tokens': {'words': ['我', '喜欢', '美妆', '里面', '的', '碧唇', '果酸', '面膜', '!']}}


    Is there a parameter of pytest.mark.parametrize that can make the unicode to be shown as valid Chinese characters?

    \u6211\u559c\u6b22\u7f8e\u5986\u91cc\u9762\u7684\u78a7\u5507\u679c\u9178\u9762\u819c!


    I am using pytest in PyCharm.

    Continue reading...

Compartilhe esta Página