Migrate test_error_diffs.py from testdir to pytester (#7971)
This commit is contained in:
parent
6cddeb8cb3
commit
aa843746a4
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue