Skip to content

Commit 56ce5b6

Browse files
authored
finish migrating test_warning.py from testdir to pytester
1 parent 37fe8ec commit 56ce5b6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

testing/test_warnings.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import pytest
88
from _pytest.fixtures import FixtureRequest
9-
from _pytest.pytester import Testdir
109
from _pytest.pytester import Pytester
1110

1211
WARNINGS_SUMMARY_HEADER = "warnings summary"
@@ -18,7 +17,7 @@ def pyfile_with_warnings(pytester: Pytester, request: FixtureRequest) -> str:
1817
pytester.syspathinsert()
1918
test_name = request.function.__name__
2019
module_name = test_name.lstrip("test_") + "_module"
21-
test_file = testdir.makepyfile(
20+
test_file = pytester.makepyfile(
2221
"""
2322
import {module_name}
2423
def test_func():
@@ -665,7 +664,7 @@ class CapturedWarnings:
665664
def pytest_warning_recorded(cls, warning_message, when, nodeid, location):
666665
cls.captured.append((warning_message, location))
667666

668-
testdir.plugins = [CapturedWarnings()]
667+
pytester.plugins = [CapturedWarnings()]
669668

670669
return CapturedWarnings
671670

0 commit comments

Comments
 (0)