$npx skillfedfor your agent

pytest-socket

Pytest Plugin to disable socket calls during tests

Worth itPyPI TestingReleased May 202613.9M downloads / moMITPure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — pytest_socket-0.8.0-py3-none-any.whl
v0.8.0 · released 2026-05-21 · Python >=3.10 · 1 runtime deps: pytest

Yes. This is a focused, well-maintained tool with low install friction and no security issues. It solves a real problem—preventing accidental network calls in tests—and integrates cleanly with pytest via CLI flags, config, or fixtures. The MIT license is permissive and the active maintenance (recent release, active repo) makes it reliable for production test suites.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Requires Python 3.10 or greater and pytest 7.0 or greater.
  • Low friction: pure Python wheel with only pytest as a runtime dependency.
  • Actively maintained with a recent release; last commit 2026-08-11 and 342 repository stars indicate ongoing support.

License · maintenance · safety

MIT (permissive) — MIT license (permissive) means you can use, modify, and distribute this plugin freely in commercial and open-source projects with minimal restrictions.

last release 2026-05-21 (85 days) · last repo commit 2026-08-11 · 342 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 13,881,633 downloads/mo, #1,260 on PyPI

Verify before relying

pip install pytest-socket

# In pytest.ini or setup.cfg:
[pytest]
addopts = --disable-socket

# Or in conftest.py:
from pytest_socket import disable_socket

def pytest_runtest_setup():
    disable_socket()
  • Whether the plugin works with pytest plugins that also patch socket at module or session scope.
  • Performance overhead of socket interception across large test suites.
  • Compatibility with async testing frameworks beyond the documented Unix socket support.
Same gist for agents: .md · .json

What it is and what it does

pytest-socket is a pytest plugin that intercepts Python's socket interface to prevent network calls during test execution. It works by globally disabling socket access or by restricting connections to an allowlist of specific hosts, IP addresses, or CIDR ranges. You can apply these restrictions via CLI flags (like `--disable-socket`), pytest configuration files, or per-test via fixtures and markers.

The plugin is useful for ensuring tests remain isolated and deterministic by catching accidental or unintended network dependencies. It supports selective allowlisting, Unix domain socket access for async testing, and per-test overrides. The plugin has been actively maintained since 2017 and supports Python 3.10 through 3.14.

Use it for

  • Catch tests that accidentally make real HTTP requests to external APIs instead of using mocks.
  • Enforce network isolation in CI/CD pipelines to ensure tests don't depend on external services.
  • Allow specific tests to connect to localhost or a test server while blocking all other network access.
  • Verify that async code using Unix domain sockets works correctly while blocking TCP/UDP calls.
  • Prevent DNS resolution during tests to catch hardcoded hostnames or missing mock setup.

Worth the install?

AI-flagged interpretation of the facts on this page. Verify before relying on it.

Worth it

Yes.

This is a focused, well-maintained tool with low install friction and no security issues. It solves a real problem—preventing accidental network calls in tests—and integrates cleanly with pytest via CLI flags, config, or fixtures. The MIT license is permissive and the active maintenance (recent release, active repo) makes it reliable for production test suites.

Install

pytest-socket on PyPI

Before you install

Low friction: pure Python wheel with only pytest as a runtime dependency. Actively maintained with a recent release; last commit 2026-08-11 and 342 repository stars indicate ongoing support.

Requires Python 3.10 or greater and pytest 7.0 or greater.

License in practice

MIT license (permissive) means you can use, modify, and distribute this plugin freely in commercial and open-source projects with minimal restrictions.

Quickstart

pip install pytest-socket

# In pytest.ini or setup.cfg:
[pytest]
addopts = --disable-socket

# Or in conftest.py:
from pytest_socket import disable_socket

def pytest_runtest_setup():
    disable_socket()

Verify before relying

  • Whether the plugin works with pytest plugins that also patch socket at module or session scope.
  • Performance overhead of socket interception across large test suites.
  • Compatibility with async testing frameworks beyond the documented Unix socket support.

Package facts

LicenseMIT permissive
Python supportSupports the current Python release >=3.10
Install frictionLow. Pure-Python wheel
Runtime dependencies
1 package
pytest
MaintenanceActively maintained 85 days since the last release
Last repo commit
First released
Downloads13,881,633 / month, #1,260 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: TestingTyping :: Typed

Evidence: pytest_socket-0.8.0-py3-none-any.whl

Tags

Capabilities
pytest network isolationdisable socket calls in testsprevent network access during testingpytest socket blockingtest network restrictionspytest DNS blockingsocket call interception
Topics
test-isolationnetwork-mocking

Let your AI agent find packages like this

Example. Real query, live index.

You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.

wish › “pytest network isolation”

  • pytest-socketA pytest plugin that blocks or restricts socket calls during tests,…
  • pytest-responsesAutomatically mocks HTTP requests across your pytest test suite using…
  • pytest-recordingA pytest plugin that records and replays HTTP traffic using VCR.py,…

Give your agent the search over MCP, or paste the wish link into any chat.

More Testing packages

pluggy Worth it
PyPI · Libraries · released May 2025

Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.

Install it if you're building an extensible application or framework.

MITpure Python · 3.9+aging
1.3Bdownloads / mo
pytest Worth it
PyPI · Libraries · released Jun 2026

pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.

MITpure Python · 3.10+
1.1Bdownloads / mo
virtualenv Worth it
PyPI · Libraries · released Aug 2026

virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.

MITpure Python · 3.9+
532.9Mdownloads / mo
coverage Worth it
PyPI · Testing · released Aug 2026

Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.

Install it if you want to measure test completeness or enforce coverage thresholds in your project.

permissive licensepure Python · 3.10+
335.8Mdownloads / mo
pytest-asyncio Worth it
PyPI · Testing · released May 2026

pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.

Install it if you write tests for any asyncio-based code.

Apache-2.0pure Python · 3.10+
275.9Mdownloads / mo
pytest-json-ctrf Worth it
PyPI · Testing · released Jul 2026

A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.

Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.

MITpure Python · 3.8+
273.0Mdownloads / mo

See also pytest-timeout · pytest-logging · pytest-reverse · pytest-helpers-namespace · pytest-freezegun · portpicker · pytest-run-parallel · pytest-threadleak · landlock