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 sys
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from _pytest.pytester import Pytester
|
||||||
|
|
||||||
|
|
||||||
TESTCASES = [
|
TESTCASES = [
|
||||||
|
@ -274,9 +275,9 @@ if sys.version_info[:2] >= (3, 7):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("code, expected", TESTCASES)
|
@pytest.mark.parametrize("code, expected", TESTCASES)
|
||||||
def test_error_diff(code, expected, testdir):
|
def test_error_diff(code: str, expected: str, pytester: Pytester) -> None:
|
||||||
expected = [line.lstrip() for line in expected.splitlines()]
|
expected_lines = [line.lstrip() for line in expected.splitlines()]
|
||||||
p = testdir.makepyfile(code)
|
p = pytester.makepyfile(code)
|
||||||
result = testdir.runpytest(p, "-vv")
|
result = pytester.runpytest(p, "-vv")
|
||||||
result.stdout.fnmatch_lines(expected)
|
result.stdout.fnmatch_lines(expected_lines)
|
||||||
assert result.ret == 1
|
assert result.ret == 1
|
||||||
|
|
Loading…
Reference in New Issue