diff options
author | Daniel Hahler <github@thequod.de> | 2019-11-03 23:02:30 +0100 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-11-20 05:24:18 +0100 |
commit | 2228ccbfb412e58138e88101876187008bb22346 (patch) | |
tree | 5886977cab55be8715426711b5ad13f2007091c0 /testing/test_pytester.py | |
parent | 7e5ad314287a5c86856efea13c04333d7baf3643 (diff) | |
download | pytest-2228ccbfb412e58138e88101876187008bb22346.tar.gz |
pytester: reset log output in _match_lines (#70)
This is necessary for when using e.g. `no_fnmatch_line` after it.
Factor it out into `_fail`.
(cherry picked from commit aade7ed0045ba32557ef8565cbab28a2c91053a7)
Ref: https://github.com/pytest-dev/pytest/pull/5914#issuecomment-549182242
Diffstat (limited to 'testing/test_pytester.py')
-rw-r--r-- | testing/test_pytester.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 758e999dc..5bdbacdd0 100644 --- a/testing/test_pytester.py +++ b/testing/test_pytester.py @@ -530,7 +530,7 @@ def test_no_matching(function): ] else: assert obtained == [ - "nomatch: '{}'".format(good_pattern), + " nomatch: '{}'".format(good_pattern), " and: 'cachedir: .pytest_cache'", " and: 'collecting ... collected 1 item'", " and: ''", @@ -542,6 +542,14 @@ def test_no_matching(function): func(bad_pattern) # bad pattern does not match any line: passes +def test_no_matching_after_match(): + lm = LineMatcher(["1", "2", "3"]) + lm.fnmatch_lines(["1", "3"]) + with pytest.raises(pytest.fail.Exception) as e: + lm.no_fnmatch_line("*") + assert str(e.value).splitlines() == ["fnmatch: '*'", " with: '1'"] + + def test_pytester_addopts(request, monkeypatch): monkeypatch.setenv("PYTEST_ADDOPTS", "--orig-unused") |