diff options
author | Ran Benita <ran@unusedvar.com> | 2020-12-05 21:51:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 21:51:20 +0200 |
commit | 760a73c08ce51d6556086988aee749978334ef91 (patch) | |
tree | b57fe9b88ef41910a92edf402a1064d7bb05b370 /testing/test_recwarn.py | |
parent | 954151cdbdcfe348aadbc8098c62abf46e766b02 (diff) | |
parent | f1e6fdcddbfe8991935685ccc5049dd957ec4382 (diff) | |
download | pytest-760a73c08ce51d6556086988aee749978334ef91.tar.gz |
Merge pull request #8017 from bluetech/typing-public-fixtures
Export types of builtin fixtures for type annotations
Diffstat (limited to 'testing/test_recwarn.py')
-rw-r--r-- | testing/test_recwarn.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/testing/test_recwarn.py b/testing/test_recwarn.py index 1aa0b5651..91efe6d23 100644 --- a/testing/test_recwarn.py +++ b/testing/test_recwarn.py @@ -29,7 +29,7 @@ def test_recwarn_functional(pytester: Pytester) -> None: class TestWarningsRecorderChecker: def test_recording(self) -> None: - rec = WarningsRecorder() + rec = WarningsRecorder(_ispytest=True) with rec: assert not rec.list warnings.warn_explicit("hello", UserWarning, "xyz", 13) @@ -46,7 +46,7 @@ class TestWarningsRecorderChecker: def test_warn_stacklevel(self) -> None: """#4243""" - rec = WarningsRecorder() + rec = WarningsRecorder(_ispytest=True) with rec: warnings.warn("test", DeprecationWarning, 2) @@ -54,21 +54,21 @@ class TestWarningsRecorderChecker: from _pytest.recwarn import WarningsChecker with pytest.raises(TypeError): - WarningsChecker(5) # type: ignore + WarningsChecker(5, _ispytest=True) # type: ignore[arg-type] with pytest.raises(TypeError): - WarningsChecker(("hi", RuntimeWarning)) # type: ignore + WarningsChecker(("hi", RuntimeWarning), _ispytest=True) # type: ignore[arg-type] with pytest.raises(TypeError): - WarningsChecker([DeprecationWarning, RuntimeWarning]) # type: ignore + WarningsChecker([DeprecationWarning, RuntimeWarning], _ispytest=True) # type: ignore[arg-type] def test_invalid_enter_exit(self) -> None: # wrap this test in WarningsRecorder to ensure warning state gets reset - with WarningsRecorder(): + with WarningsRecorder(_ispytest=True): with pytest.raises(RuntimeError): - rec = WarningsRecorder() + rec = WarningsRecorder(_ispytest=True) rec.__exit__(None, None, None) # can't exit before entering with pytest.raises(RuntimeError): - rec = WarningsRecorder() + rec = WarningsRecorder(_ispytest=True) with rec: with rec: pass # can't enter twice |