Skip to content
Myr

Test Requests entrypoints (#330)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Test Requests entrypoints * Show summary of unsuccessful tests

authored by Florimond Manca · committed by GitHub · parent 0c4460e · Browse files · 4 files+50 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+50 added−1 removed

  • tests:+47 added−0 removed
  • other:+3 added−1 removed

4 files+50 added−1 removed

added:tests/requests_compat/__init__.py
added:tests/requests_compat/conftest.py+17 added
1import sys23import pytest45import httpx678def pytest_configure(config):9 # Allow to 'import requests' without having to write 'import httpx as requests'.10 # This means we *could* literally copy-paste Requests test code as-is, if relevant.11 sys.modules["requests"] = httpx121314@pytest.fixture(autouse=True)15def patch_httpx(monkeypatch):16 """Monkey-patch Requests APIs onto HTTPX."""17 monkeypatch.setattr(httpx, "session", httpx.Client, raising=False)
added:tests/requests_compat/test_api.py+30 added
1"""Test compatibility with the Requests high-level API."""2import pytest34import requests567@pytest.mark.copied_from(8 "https://github.com/psf/requests/blob/v2.22.0/tests/test_requests.py#L61-L70"9)10def test_entrypoints():11 requests.session12 requests.session().get13 requests.session().head14 requests.get15 requests.head16 requests.put17 requests.patch18 requests.post192021@pytest.mark.copied_from(22 "https://github.com/psf/requests/blob/v2.22.0/tests/test_requests.py#L72",23 changes=["added noqa comment to silence flake8"],24)25@pytest.mark.xfail(26 reason="PoolManager has no obvious equivalent in HTTPX", raises=ImportError27)28def test_poolmanager_entrypoint():29 # Not really an entry point, but people rely on it.30 from requests.packages.urllib3.poolmanager import PoolManager # noqa: F401
modified:setup.cfg+3 added-1 removed
14 unmodified lines
15line_length = 8816multi_line_output = 31718[tool:pytest]19addopts = --cov=httpx --cov=tests --cov-report=term-missing19addopts = --cov=httpx --cov=tests --cov-report=term-missing -rxXs20markers =21 copied_from(source, changes=None): mark test as copied from somewhere else, along with a description of changes made to accodomate e.g. our test setup