Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork0
Replace Starlette's TestClient from `requests` to `httpx`! 🎉
License
Kludex/bump-testclient
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Starlette 0.21.0 changed theTestClient implementation: it replaced therequests library withhttpx.As those libraries have different APIs, this change break tests for Starlette's users.
Thiscodemod makes the transition to Starlette 0.21.0 easier.It makes the changes needed to make the tests work again.
Make your life easier. Suggested bySebastián Ramírez as a joke, but well... I did it.
- Replace
client.<method>(...)byclient.request("<method>", ...)
The methods ("delete", "get", "head", "options") doesn't accept thecontent,data,json andfiles parameters.
Conditions for this transformation:
- Using
client.<method>and<method>in ("delete", "get", "head", "options"). - Using
content,data,jsonorfilesparameters.
- Replace
client.<method>(..., allow_redirects=...)byclient.<method>(..., follow_redirects=...)
HTTPX usesfollow_redirects instead ofallow_redirects.
- Replace
client.<method>(..., data=...)byclient.<method>(..., content=...)
If the argument passed todata is either text or bytes,content should be used instead.
Conditions for this to happen:
dataparameter receives a bytes/text argument.
pip install bump-testclient
Run the following on the repository you want to format:
python -m bump_testclient<files>
You can also use the pre-commit. Add the following to your.pre-commit-config.yaml file:
-repo:https://github.com/Kludex/bump-testclientrev:0.3.0hooks: -id:bump_testclient
This project is licensed under the terms of the MIT license.
About
Replace Starlette's TestClient from `requests` to `httpx`! 🎉
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.