pytest-network
A simple pytest plugin to disable network on socket level.
Installation
$ pip install pytest-network
Usage
pytest-network has a flag --disable-network that will raise an error
if tests will try to use socket.socket.connect
You can use it directly like:
$ python3 -m pytest --disable-network
or add this flag as the default behavior in your pytest.ini:
[pytest]
addopts = --disable-network
Also you can directly disable network:
import requests
def test_network_request_raises_error(disable_network):
response = requests.get('https://github.com') # this will raise an exception
assert response.status_code == 200
or directly enable (if you have default --disable-network flag):
import requests
def test_network_request_is_ok(disable_network):
response = requests.get('https://github.com')
assert response.status_code == 200 # this will pass
Development
To setup development environment you must first create a virtual environment. For example:
$ python3.8 -m venv <venv-name>
After that install all requirements:
$ pip install -r requirements.txt
And install plugin itself (inside project directory and virtual environment):
$ pip install -e .
Check that tests are running:
$ make test
Contributing
We would love you to contribute to our project. It's simple:
- Create an issue with bug you found or proposal you have. Wait for approve from maintainer.
- Create a pull request. Make sure all checks are green.
- Fix review comments if any.
- Be awesome.
Here are useful tips:
- You can run all checks and tests with make check. Please do it before TravisCI does.
- We use BestDoctor python styleguide. Sorry, styleguide is available only in Russian for now.
- We respect Django CoC. Make soft, not bullshit.
Metadata
Release files for pytest-network 0.0.1
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 |
|---|---|---|---|---|
| pytest_network-0.0.1.tar.gz | 2.8 kB | Without provenance | Details for pytest_network-0.0.1.tar.gz |
Release files / pytest_network-0.0.1.tar.gz
| Download URL | pytest_network-0.0.1.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b109e2ad27f4ab0f13c1796a9b419bab1d503ea3b5ae3ca37363486ccceaa3f
|
|
BLAKE2b-256 checksum How to use checksums |
8cf22b381c56e0dbc7404fb104277bc731865786db7c005351441561ec1a9e25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3
|
Security for pytest-network 0.0.1
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.