You are here: Home / LBN / Up2date / CI/CD / BastionLinux 36 / python3-pytest-socket-0.7.0-1.lbn36.noarch

python3-pytest-socket-0.7.0-1.lbn36.noarch

Package Attributes
RPM  python3-pytest-socket-0.7.0-1.lbn36.noarch.rpm Architecture  noarch Size  23808 Created  2025/05/19 12:49:45 UTC
Package Specification
Summary Pytest Plugin to disable socket calls during tests
Group Unspecified
License ZPL
Home Page https://pypi.org/project/pytest-socket
Description

pytest-socket

A plugin to use with Pytest to disable or restrict socket calls during tests to ensure network calls are prevented.

Features

Disables all network calls flowing through Python's socket interface.

Requirements

Pytest 6.2.5 or greater

Installation You can install pytest-socket via pip from PyPI: pip install pytest-socket

or add to your pyproject.toml for poetry: [tool.poetry.dev-dependencies] pytest-socket = "*"

Usage Run pytest --disable-socket, tests should fail on any access to socket or libraries using socket with a SocketBlockedError. To add this flag as the default behavior, add this section to your pytest.ini: [pytest] addopts = --disable-socket

or add this to your setup.cfg: [tool:pytest] addopts = --disable-socket

or update your conftest.py to include: from pytest_socket import disable_socket

def pytest_runtest_setup(): disable_socket()

If you exceptionally want to enable socket for one particular execution pass --force-enable-socket. It takes

Requires
rpmlib(PayloadFilesHavePrefix)  
rpmlib(PayloadIsZstd)  
rpmlib(PartialHardlinkSets)  
rpmlib(CompressedFileNames)  
rpmlib(FileDigests)  
Provides
python-pytest-socket
python3-pytest-socket
python3.10-pytest-socket
python3.10dist(pytest-socket)
python3dist(pytest-socket)
Obsoletes
python-pytest-socket

Document Actions