【发布时间】:2020-09-18 05:21:05
【问题描述】:
在字符串值中有一个带有单引号的 pytest 参数。例如,
@pytest.mark.parametrize(
'message1, code, message2', [
('test_exception_message', 'error_code_example', ''apples' are in the 'basket'')])
message2 = 'apples' are in the 'basket'
如何处理引号?谢谢。
【问题讨论】:
-
参数使用双引号即可,例如
"'apples' are in the 'basket'"。或者你可以逃脱他们:'\'apples\' are in the \'basket\''. -
它有效。谢谢。