Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pytest-network

Package Overview
Dependencies
Maintainers
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pytest-network

A simple plugin to disable network on socket level.

  • 0.0.1
  • PyPI
  • Socket score

Maintainers
3

pytest-network

Build Status Maintainability Test Coverage

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.

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc