Hi, thank you for this excellent plugin. While it works fine with Flask's test client, the plugin blocks starlette's TestClient (used by FastAPI). Here's a self-contained example that I'd expect to pass with pytest:
from pytest_socket import disable_socket
from starlette.responses import HTMLResponse
from starlette.testclient import TestClient
def pytest_runtest_setup():
disable_socket()
async def app(scope, receive, send):
assert scope['type'] == 'http'
response = HTMLResponse('<html><body>Hello, world!</body></html>')
await response(scope, receive, send)
def test_app():
client = TestClient(app)
response = client.get('/')
assert response.status_code == 200
The above returns a:
E pytest_socket.SocketBlockedError: A test tried to use socket.socket
Would it be possible to make this work with FastAPI/Starlette?
Hi, thank you for this excellent plugin. While it works fine with Flask's test client, the plugin blocks starlette's TestClient (used by FastAPI). Here's a self-contained example that I'd expect to pass with
pytest:The above returns a:
Would it be possible to make this work with FastAPI/Starlette?