pytest_httpx
pytest_httpx copied to clipboard
Setup httpx_mock via marker instead of fixtures
Resolves #137
We want to be able to configure how the httpx_mock fixture behaves at different scopes. A pytest marker can be used at module, class, or test scope and so is what is used here.
Providing a non-default value from the fixtures will emit a DeprecationWarning for each test with the exact marker it can be replaced with:
=================================== warnings summary ===================================
tests/test_tmp.py::test_a
tests/test_tmp.py::test_b
/.../pytest_httpx/__init__.py:56: DeprecationWarning: The assert_all_responses_were_requested and non_mocked_hosts fixtures are deprecated.
Use the following marker instead:
pytest.mark.httpx_mock(assert_all_responses_were_requested=False)
warnings.warn(
tests/test_tmp.py::test_c
/.../pytest_httpx/__init__.py:56: DeprecationWarning: The assert_all_responses_were_requested and non_mocked_hosts fixtures are deprecated.
Use the following marker instead:
pytest.mark.httpx_mock(non_mocked_hosts=['example.com'])
warnings.warn(
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
Guys, thank you so much for this pullrequest. It's a great library, but it's a feature it really lacks
I agree, I plan on looking to this as soon as I have some free time. hang in there
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
This was released as part of version 0.31.0 today
Thanks!