Remove usage of re.compile in example code

This commit is contained in:
Alessio Bogon 2019-02-19 14:21:41 +01:00 committed by GitHub
parent 956081cded
commit 2a1c45166e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -974,13 +974,13 @@ Using unicode in the feature files
---------------------------------- ----------------------------------
As mentioned above, by default, utf-8 encoding is used for parsing feature files. As mentioned above, by default, utf-8 encoding is used for parsing feature files.
For steps definition, you can both use unicode- and bytestrings equally. For steps definition, you should use unicode strings, which is the default in python 3.
However, for argumented steps, if you need to use unicode symbols in it's regular expression, use `u` sign with regex: If you are on python 2, make sure you use unicode strings by prefixing them with the `u` sign.
.. code-block:: python .. code-block:: python
@given(re.compile(u"у мене є рядок який містить '{0}'".format('(?P<content>.+)'))) @given(parsers.re(u"у мене є рядок який містить '{0}'".format(u'(?P<content>.+)')))
def there_is_a_string_with_content(content, string): def there_is_a_string_with_content(content, string):
"""Create string with unicode content.""" """Create string with unicode content."""
string['content'] = content string['content'] = content