reqMock
Mock requests library like HTTPToolkit in python3
Installation
pip install reqMock
Example:
Original code
import requests
print(requests.get("https://google.com").text)
Import in first line of code
from reqMock import mockControl as mock
Enable mock
# To enable mock
mock.set(enable = True)
# To disable mock
mock.set(enable = False)
Mock https://google.com to another website
mock.add(
url = "https://google.com", # mock 'from'
method = "GET", # method 'from'
mockCheck = "url", # method mock ('host', 'url', 'match')
mockMethod = "url", # mock to 'url' or 'text'
to = "https://youtube.com", # data
# headers = None, # change header of this request
# data = None, # change data of this request
# status_code = 200 # change status code of this request
)
Mock https://youtube.com to custom result
mock.add(
url = "https://youtube.com",
method = "GET",
mockCheck = "url",
mockMethod = "text",
to = "Hello World!",
# headers = None,
# data = None,
# status_code = 200
)
Enable showQuery to print info from requests
mock.set(showQuery = True) # Default is False
# You will see output requests like this
# ">> requests: GET: https://google.com (headers={'abc': 'def'})" and below is result output
Enable showResult to print result output from requests
mock.set(showResult = True) # Default is False
# You will see output requests like this
# ">> result: GET: https://google.com" and below is result output
Enable showTrace to print call stack trace
mock.set(showTrace = True) # Default is False
# You will see detailed call stack trace like this:
# >> trace:
# 1. <module> of <main> at line 10 -> main()
# 2. main() of <main> at line 5 -> result = func_a()
# 3. func_a(
# param1='test_value',
# param2='custom_value'
# ) of <main> at line 2 -> return func_b()
# 4. func_b(
# arg1='test_value',
# arg2='custom_value'
# ) of <main> at line 3 -> return requests.get("https://httpbin.org/get")
# 5. requests.get(url='https://httpbin.org/get', params={'key': 'value'})
Redirect output of show to file
mock.set(stdout = open('out.txt', 'w'))
# Output of 'show' option will write to file instead of write to output
If you want to rename this module for hide from check
# Open a python3 shell
from reqMock import mockControl as mock
# Example change module name from 'reqMock' to 'Khanh'
mock.set(moduleName = "Khanh")
# Choose 'y' and new name will applied in new session
# For new session, import it by using new name
from Khanh import mockControl as mock
Metadata
Release files for reqMock 0.0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reqmock-0.0.0.5.tar.gz | 8.1 kB | Without provenance | Details for reqmock-0.0.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reqmock-0.0.0.5-py3-none-any.whl | Python 3 | none | any | Details for reqmock-0.0.0.5-py3-none-any.whl |
Total release size: 14.7 kB
Release files / reqmock-0.0.0.5.tar.gz
| Download URL | reqmock-0.0.0.5.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
69028c3a0d5c8014788cf3d0a047ac66e8889b6e83089648d39f60433225d5fe
|
|
BLAKE2b-256 checksum How to use checksums |
161b772ee7e7ef1521eb308a49760461ffc2b32b1877da6972a9fe912a34ca65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / reqmock-0.0.0.5-py3-none-any.whl
| Download URL | reqmock-0.0.0.5-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab3db9c7e01a6c260337df541098722c7306362e5de772da195f79dfe157f52b
|
|
BLAKE2b-256 checksum How to use checksums |
93fcca128aea0e46576f1f70a15255e6af0cf326b2957b3b6463d446a89428ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for reqMock 0.0.0.5
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.