danielsgriffin
21
How do I do a doctest that requires sending an escaped quotation mark in the parameters? Like this: parameter: '"custom instructions" in Siri' Tired: >>> slugify("'\"custom instructions\" in Siri'", args) But I get a syntax error.

Pro Search

6 steps completed

Answer

To write a doctest that requires sending an escaped quotation mark in the parameters, you can use double quotes to enclose the string and single quotes inside the string, or vice versa. In your case, you can modify the doctest like this:
python
>>> slugify('"custom instructions" in Siri', args)
Here, the outer double quotes enclose the string, and the inner double quotes are part of the string itself. This should resolve the syntax error you encountered.

Related

How to escape quotation marks in Python doctests
Can I use double quotes in Python doctests
How to pass a string with quotes as a parameter in Python doctests