mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2026-11-02 20:30:30 -06:00
Short-circuit HTTP requests in tests (#12772)
This commit is contained in:
1 parent
070f2c1db0
commit
03b9134ee0
12 files changed
+90
-50
No files matched your search
@@ -4,6 +4,7 @@ import gettext
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import docutils
|
||||
@@ -60,3 +61,20 @@ def _cleanup_docutils() -> Iterator[None]:
|
||||
sys.path[:] = saved_path
|
||||
|
||||
_clean_up_global_state()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def _http_teapot(monkeypatch: pytest.MonkeyPatch) -> Iterator[None]:
|
||||
"""Short-circuit HTTP requests.
|
||||
|
||||
Windows takes too long to fail on connections, hence this fixture.
|
||||
"""
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/418
|
||||
response = SimpleNamespace(status_code=418)
|
||||
|
||||
def _request(*args, **kwargs):
|
||||
return response
|
||||
|
||||
with monkeypatch.context() as m:
|
||||
m.setattr('sphinx.util.requests._Session.request', _request)
|
||||
yield
|
||||
Reference in new issue
Block a user