Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce no_fnmatch_line/no_re_match_line in pytester
The current idiom is to use: assert re.match(pat, result.stdout.str()) Or assert line in result.stdout.str() But this does not really give good results when it fails. Those new functions produce similar output to ther other match lines functions.
- Loading branch information
1 parent
c1361b4
commit 4163556
Showing
3 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
``pytester`` learned two new functions, `no_fnmatch_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_fnmatch_line>`_ and | ||
`no_re_match_line <https://docs.pytest.org/en/latest/reference.html#_pytest.pytester.LineMatcher.no_re_match_line>`_. | ||
|
||
The functions are used to ensure the captured text *does not* match the given | ||
pattern. | ||
|
||
The previous idiom was to use ``re.match``: | ||
|
||
.. code-block:: python | ||
assert re.match(pat, result.stdout.str()) is None | ||
Or the ``in`` operator: | ||
|
||
.. code-block:: python | ||
assert text in result.stdout.str() | ||
But the new functions produce best output on failure. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters