Skip to main content

bump-testclient

Package version

Starlette 0.21.0 changed the TestClient implementation: it replaced the requests library with httpx. As those libraries have different APIs, this change break tests for Starlette's users.

This codemod makes the transition to Starlette 0.21.0 easier. It makes the changes needed to make the tests work again.

Why?

Make your life easier. Suggested by Sebastián Ramírez as a joke, but well... I did it.

Transformations

  1. Replace client.<method>(...) by client.request("<method>", ...)

The methods ("delete", "get", "head", "options") doesn't accept the content, data, json and files parameters.

Conditions for this transformation:

  • Using client.<method> and ` in ("delete", "get", "head", "options").
  • Using content, data, json or files parameters.
  1. Replace client.<method>(..., allow_redirects=...) by client.<method>(..., follow_redirects=...)

HTTPX uses follow_redirects instead of allow_redirects.

  1. Replace client.<method>(..., data=...) by client.<method>(..., content=...)

If the argument passed to data is either text or bytes, content should be used instead.

Conditions for this to happen:

  • data parameter receives a bytes/text argument.

Installation

pip install bump-testclient

Usage

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-testclient
    rev: 0.3.0
    hooks:
      - id: bump_testclient

License

This project is licensed under the terms of the MIT license.

Metadata

Release files for bump-testclient 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for bump-testclient 0.3.0
File Interpreter ABI Platform Actions
bump_testclient-0.3.0-py3-none-any.whl Python 3 none any Details for bump_testclient-0.3.0-py3-none-any.whl

Release files / bump_testclient-0.3.0-py3-none-any.whl

Download URL bump_testclient-0.3.0-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55139fe9aed45702a0215701ef6d37ad7dd449813bd95e65b58cd7430637964f
BLAKE2b-256 checksum
How to use checksums
3028b2f62ebcd2fb35892e788c497b2d4d0629d7c83559e8f3855acafaa626f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Security for bump-testclient 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page