MockTransport doesn't set the elapsed property
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 78
- Avg merge
- 8h 59m
- Merged PRs (30d)
- 24
Description
Originally opened by
@ionelmcon 2025-11-24 20:54:00 in encode/httpx
This is not a nice solution:
def handler(request):
resp = httpx.Response(200, json={"text": "Hello, world!"})
resp.elapsed = timedelta(.......
return resp
If you have dispatch code in that handler that can easily get boilerplatey.
I think httpx should do either of these:
- MockTransport take the duration as an optional argument
- httpx provide a decorator, so you can wrap your handler in it
- automatically set a duration of 0 for manually created Response objects - why error out if the data is already there?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating MockTransport and the Response elapsed property in the repository, then inspect how manually created responses are handled. Compare the three proposed behaviors and existing transport tests; done means an agreed behavior is implemented and covered by tests without requiring handler boilerplate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100