A thin layer of sugar atop Python's mock.
Reason this release was yanked:
rc
Project description
mockish
A thin layer of sugar atop Python's mock.
Code Repo | https://github.com/fresh2dev/mockish |
Mirror Repo | https://www.Fresh2.dev/code/r/mockish |
mockish
is a small tool I built to make life easier when writing tests in Python. It provides:
- Explicit alternatives to the nuanced
mock.Mock(side_effect=...)
argument, including:
mockish.Mock(return_value=...)
mockish.Mock(return_call=...)
mockish.Mock(return_once=...)
mockish.Mock(return_each=...)
mockish.Mock(return_exception=...)
-
To help with mocking HTTP requests,
mockish
makes it easy to createResponse
objects to use as the return value for your Mock. -
To serve as a drop in replacement for
mock
, themockish
module exportsmockish.patch
.
To be clear, mockish
doesn't do much on its own, instead relying fully on the native mock
library. This library just provides some syntactic sugar atop mock
that acts in a way that I consider more intuitive.
If this project delivers value to you, please provide feedback, code contributions, and/or funding.
See my other projects @ https://www.Fresh2.dev/projects
Install
Use
See the reference docs for
Mock Return Values
...
Mock Objects
...
Mock HTTP Responses
mock_resp: httpx.Response = mockish.httpx.Response(
content=expected_content,
content_type=expected_content_type,
status_code=expected_status_code,
headers=expected_headers,
)
assert isinstance(mock_resp, httpx.Response)
mock_resp: httpx.Response = mockish.httpx.Response.from_dict({"hello": str(uuid4())})
print(mock_resp.json())
Complete Example
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mockish-0.0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2646f963507ebedafaa7771c45bb4b59b11ba0cb13c4549fd7ffaedc55811e62 |
|
MD5 | 8f37c64c23e58b2555c255c311416e08 |
|
BLAKE2b-256 | a23256c9d6bbe96557637e9ba78fe4425a99a8644ade6f71380138ca153444ce |