Migrate test_error_diffs.py from testdir to pytester (#7971)

This commit is contained in:
Christine Mecklenborg 2020-10-30 15:12:40 -05:00 committed by GitHub
parent 6cddeb8cb3
commit aa843746a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -7,6 +7,7 @@ See https://github.com/pytest-dev/pytest/issues/3333 for details.
import sys
import pytest
from _pytest.pytester import Pytester
TESTCASES = [
@ -274,9 +275,9 @@ if sys.version_info[:2] >= (3, 7):
@pytest.mark.parametrize("code, expected", TESTCASES)
def test_error_diff(code, expected, testdir):
expected = [line.lstrip() for line in expected.splitlines()]
p = testdir.makepyfile(code)
result = testdir.runpytest(p, "-vv")
result.stdout.fnmatch_lines(expected)
def test_error_diff(code: str, expected: str, pytester: Pytester) -> None:
expected_lines = [line.lstrip() for line in expected.splitlines()]
p = pytester.makepyfile(code)
result = pytester.runpytest(p, "-vv")
result.stdout.fnmatch_lines(expected_lines)
assert result.ret == 1