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在上面的单元pytest中,如果我运行它,输出就在下面:
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': ['我', '喜欢', '美妆', '里面', '的', '碧唇', '果酸', '面膜', '!']}}是否有pytest.mark.parametrize的参数可以使unicode显示为有效的中文字符?
\u6211\u559c\u6b22\u7f8e\u5986\u91cc\u9762\u7684\u78a7\u5507\u679c\u9178\u9762\u819c!我在PyCharm中使用pytest。
发布于 2021-12-14 22:59:41
显示非ascii测试ids是pytest代码库中特别棘手的部分。
在编写本报告时,它们默认为off,但您可以通过pytest.ini中的一个实验性标志启用它们
[pytest]
disable_test_id_escaping_and_forfeit_all_rights_to_community_support = true$ pytest t.py -v
============================= test session starts ==============================
platform linux -- Python 3.8.10, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /tmp/y/venv/bin/python
cachedir: .pytest_cache
rootdir: /tmp/y, configfile: pytest.ini
collected 1 item
t.py::test_tokenizer_sentence[我喜欢美妆里面的碧唇果酸面膜!] PASSED [100%]
============================== 1 passed in 0.00s ===============================免责声明:我是最热的核心开发者之一。
https://stackoverflow.com/questions/70356301
复制相似问题