-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add binary body patcher and deprecation warnings * Fix <=3.9 type syntax compat * Use a clearer and unified deprecation warning * Fix body matcher binary argument not passing through * Add history entries
- Loading branch information
1 parent
a790994
commit 1e930cb
Showing
14 changed files
with
310 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import pytest | ||
import warnings | ||
|
||
import pook | ||
from pook.response import _BinaryDefault | ||
|
||
|
||
pook.apply_binary_body_fix() | ||
|
||
|
||
def pytest_configure(config: pytest.Config): | ||
config.addinivalue_line( | ||
"markers", | ||
"undo_suppress_own_warnings: undo pook-warning suppression", | ||
) | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def _suppress_own_deprecation_warnings(request: pytest.FixtureRequest): | ||
undo = request.node.get_closest_marker("undo_suppress_own_warnings") | ||
|
||
if undo: | ||
# Only relevant when testing the warnings themselves | ||
yield | ||
return | ||
|
||
with warnings.catch_warnings(record=True) as recorded_warnings: | ||
yield | ||
|
||
for warning in recorded_warnings: | ||
if "Non-binary pook response bodies are deprecated" not in str(warning.message): | ||
warnings.showwarning(warning) | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def without_binary_body_fix(): | ||
_BinaryDefault.fixed = False | ||
yield | ||
pook.apply_binary_body_fix() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.