Skip to content

Commit 6a9e073

Browse files
bluetechKriechi
authored andcommitted
Avoid using _pytest
Even though `MonkeyPatch` will become public in the next pytest release (as `pytest.MonkeyPatch`), it's better to avoid the `_pytest` namespace.
1 parent ec0f9e6 commit 6a9e073

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

setup.cfg

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ combine_as_imports=True
2121
force_grid_wrap=0
2222
include_trailing_comma=True
2323
known_first_party=wsproto, test
24-
known_third_party=h11, pytest, _pytest
24+
known_third_party=h11, pytest
2525
line_length=88
2626
multi_line_output=3
2727
no_lines_before=LOCALFOLDER
@@ -51,5 +51,3 @@ warn_unused_ignores = True
5151
ignore_missing_imports = True
5252
[mypy-pytest.*]
5353
ignore_missing_imports = True
54-
[mypy-_pytest.*]
55-
ignore_missing_imports = True

test/test_permessage_deflate.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from typing import cast, Optional, Sequence, TYPE_CHECKING
33

44
import pytest
5-
from _pytest.monkeypatch import MonkeyPatch
65

76
from wsproto import extensions as wpext, frame_protocol as fp
87

@@ -348,7 +347,7 @@ def test_inbound_bad_zlib_payload(self) -> None:
348347
result2 = ext.frame_inbound_payload_data(proto, compressed_payload)
349348
assert result2 is fp.CloseReason.INVALID_FRAME_PAYLOAD_DATA
350349

351-
def test_inbound_bad_zlib_decoder_end_state(self, monkeypatch: MonkeyPatch) -> None:
350+
def test_inbound_bad_zlib_decoder_end_state(self) -> None:
352351
compressed_payload = b"x" * 23
353352

354353
ext = wpext.PerMessageDeflate()
@@ -371,9 +370,9 @@ def decompress(self, data: bytes) -> bytes:
371370
def flush(self) -> None:
372371
raise zlib.error()
373372

374-
monkeypatch.setattr(ext, "_decompressor", FailDecompressor())
375-
373+
ext._decompressor = cast("zlib._Decompress", FailDecompressor())
376374
result2 = ext.frame_inbound_complete(proto, True)
375+
377376
assert result2 is fp.CloseReason.INVALID_FRAME_PAYLOAD_DATA
378377

379378
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)