summaryrefslogtreecommitdiff
path: root/testing/test_recwarn.py
diff options
context:
space:
mode:
authorGarvit Shubham <mailme.garvit@gmail.com>2020-11-09 09:53:31 +0530
committerRan Benita <ran@unusedvar.com>2020-11-16 19:22:57 +0200
commit6fe9d2fb9f678835d5f1366b89ce7b05489957b8 (patch)
treeb4a9d9268c7f59461542cee0f798cb12a608ca0b /testing/test_recwarn.py
parent825b81ba523cb660a3bfc8d68317dab61f5a4753 (diff)
downloadpytest-6fe9d2fb9f678835d5f1366b89ce7b05489957b8.tar.gz
testing: convert test_{conftest,recwarn,tmpdir} to pytester
Diffstat (limited to 'testing/test_recwarn.py')
-rw-r--r--testing/test_recwarn.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py
index f61f8586f..1aa0b5651 100644
--- a/testing/test_recwarn.py
+++ b/testing/test_recwarn.py
@@ -3,6 +3,7 @@ import warnings
from typing import Optional
import pytest
+from _pytest.pytester import Pytester
from _pytest.recwarn import WarningsRecorder
@@ -12,8 +13,8 @@ def test_recwarn_stacklevel(recwarn: WarningsRecorder) -> None:
assert warn.filename == __file__
-def test_recwarn_functional(testdir) -> None:
- testdir.makepyfile(
+def test_recwarn_functional(pytester: Pytester) -> None:
+ pytester.makepyfile(
"""
import warnings
def test_method(recwarn):
@@ -22,7 +23,7 @@ def test_recwarn_functional(testdir) -> None:
assert isinstance(warn.message, UserWarning)
"""
)
- reprec = testdir.inline_run()
+ reprec = pytester.inline_run()
reprec.assertoutcome(passed=1)
@@ -328,9 +329,9 @@ class TestWarns:
assert str(record[0].message) == "user"
assert str(record[1].message) == "runtime"
- def test_double_test(self, testdir) -> None:
+ def test_double_test(self, pytester: Pytester) -> None:
"""If a test is run again, the warning should still be raised"""
- testdir.makepyfile(
+ pytester.makepyfile(
"""
import pytest
import warnings
@@ -341,7 +342,7 @@ class TestWarns:
warnings.warn("runtime", RuntimeWarning)
"""
)
- result = testdir.runpytest()
+ result = pytester.runpytest()
result.stdout.fnmatch_lines(["*2 passed in*"])
def test_match_regex(self) -> None: