Skip to content

Commit

Permalink
Turn scope["client"] to None on TestClient (encode#2377)
Browse files Browse the repository at this point in the history
* Remove client scope from testclient

* remove test

* Update testclient.py

---------

Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
aminalaee and Kludex committed Dec 25, 2023
1 parent 966f0fc commit 483849a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
4 changes: 2 additions & 2 deletions starlette/testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
"scheme": scheme,
"query_string": query.encode(),
"headers": headers,
"client": ["testclient", 50000],
"client": None,
"server": [host, port],
"subprotocols": subprotocols,
"state": self.app_state.copy(),
Expand All @@ -263,7 +263,7 @@ def handle_request(self, request: httpx.Request) -> httpx.Response:
"scheme": scheme,
"query_string": query.encode(),
"headers": headers,
"client": ["testclient", 50000],
"client": None,
"server": [host, port],
"extensions": {"http.response.debug": {}},
"state": self.app_state.copy(),
Expand Down
13 changes: 0 additions & 13 deletions tests/test_testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,6 @@ async def asgi(receive, send):
assert data == {"message": "test"}


def test_client(test_client_factory):
async def app(scope, receive, send):
client = scope.get("client")
assert client is not None
host, port = client
response = JSONResponse({"host": host, "port": port})
await response(scope, receive, send)

client = test_client_factory(app)
response = client.get("/")
assert response.json() == {"host": "testclient", "port": 50000}


@pytest.mark.parametrize("param", ("2020-07-14T00:00:00+00:00", "España", "voilà"))
def test_query_params(test_client_factory, param: str):
def homepage(request):
Expand Down

0 comments on commit 483849a

Please sign in to comment.