$npx skillfedfor your agent

mock-open

A better mock for file I/O

SkipPyPI Software DevelopmentReleased Apr 2020257.6K downloads / moMITSource build

Decision gist · record as of 2026-08-14

sdist only — mock-open-1.4.0.tar.gz · builds from source
v1.4.0 · released 2020-04-15

No. The package is abandoned (last release 2020-04-15, last commit 2020-10-10) with no maintenance or security updates. The standard library's mock.mock_open has likely evolved to address the gaps that motivated mock-open, and relying on unmaintained test infrastructure creates long-term risk. Use unittest.mock.mock_open or consider pytest-mock and related modern alternatives instead.AI-flagged interpretation of the facts on this page — verify before relying

Before you install

  • Installation friction is high due to source distribution format.
  • The package is abandoned—last commit was 2020-10-10 and no releases since 2020-04-15—so expect no maintenance or security updates going forward.

License · maintenance · safety

MIT (permissive) — MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions, suitable for both open-source and proprietary projects.

last release 2020-04-15 (2312 days) · last repo commit 2020-10-10 · 7 stars

0 known vulnerabilities (OSV.dev, 2026-08-14) · 257,624 downloads/mo, #8,439 on PyPI

Verify before relying

from unittest.mock import patch
from mock_open import MockOpen

mock_open = MockOpen()
mock_open["/path/to/file"].read_data = "test data"

with patch("builtins.open", mock_open):
    with open("/path/to/file", "r") as f:
        content = f.read()
  • Whether the package works reliably with modern Python versions (3.9+) despite being abandoned since 2020
  • Whether standard library mock.mock_open has since incorporated the features that made mock-open necessary
Same gist for agents: .md · .json

What it is and what it does

mock-open is a test utility that replaces the builtin open function with a mock that tracks file operations for unit testing. Unlike the standard mock.mock_open, it supports multiple file paths simultaneously, maintains file contents across separate open calls, and implements the full file API (read, write, seek, tell, readline, readlines, writelines). It's designed to let you test code that reads or writes files without touching the filesystem.

The package works by providing a MockOpen class that acts as a context manager and can be patched over builtins.open. You configure mock files by path, set their read_data or side effects, and then your code under test interacts with them as if they were real files. State persists between calls, so a write followed by a read on the same path returns what was written.

Use it for

  • Test code that reads configuration files without creating temporary files on disk
  • Verify file write operations in unit tests by checking mock call arguments and state
  • Mock multiple file paths in a single test to simulate complex I/O scenarios
  • Test error handling for file operations by setting IOError side effects on specific paths
  • Ensure file operations occur in the correct order or with expected arguments

Worth the install?

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

Skip

No.

The package is abandoned (last release 2020-04-15, last commit 2020-10-10) with no maintenance or security updates. The standard library's mock.mock_open has likely evolved to address the gaps that motivated mock-open, and relying on unmaintained test infrastructure creates long-term risk. Use unittest.mock.mock_open or consider pytest-mock and related modern alternatives instead.

Install

mock-open on PyPI

Before you install

Installation friction is high due to source distribution format. The package is abandoned—last commit was 2020-10-10 and no releases since 2020-04-15—so expect no maintenance or security updates going forward.

License in practice

MIT license is permissive, allowing free use, modification, and distribution with minimal restrictions, suitable for both open-source and proprietary projects.

Quickstart

from unittest.mock import patch
from mock_open import MockOpen

mock_open = MockOpen()
mock_open["/path/to/file"].read_data = "test data"

with patch("builtins.open", mock_open):
    with open("/path/to/file", "r") as f:
        content = f.read()

Verify before relying

  • Whether the package works reliably with modern Python versions (3.9+) despite being abandoned since 2020
  • Whether standard library mock.mock_open has since incorporated the features that made mock-open necessary

Package facts

LicenseMIT permissive
Python supportNot specified
Install frictionHigh. Source build required
Runtime dependenciesNone
MaintenanceAbandoned 2,312 days since the last release
Last repo commit
First released
Downloads257,624 / month, #8,439 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone known OSV.dev, checked 2026-08-14
Classifiers
Development Status :: 5 - Production/StableEnvironment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 2.7Programming Language :: Python :: 3Topic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Testing

Evidence: mock-open-1.4.0.tar.gz

Tags

Capabilities
mock file operationsfile I/O testingmock open replacementunit test file mockingfake file systemmock multiple filespersistent mock files
Topics
abandonedtesting-utility
PyPI keywords
testingunittesttestmockmockingpatchpatchingstubsfakesdoubles

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 › “mock file operations”

  • mock-openProvides a drop-in replacement for mock.mock_open that supports…
  • testpathTestpath provides utilities for testing code that interacts with…
  • pytest-sftpserverA pytest plugin that provides a fixture for testing SFTP client code…

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

More Software Development packages

typing-extensions Worth it
PyPI · Software Development · released Jul 2026

Provides backported and experimental type hints for Python 3.9+, allowing use of newer typing features on older Python versions and enabling early experimentation with type system PEPs before they enter the standard library.

PSF-2.0pure Python · 3.9+
1.9Bdownloads / mo
numpy Worth it
PyPI · Software Development · released Aug 2026

NumPy provides an N-dimensional array object and a comprehensive suite of mathematical, linear algebra, Fourier transform, and random number functions for scientific computing in Python.

BSD-3-Clause AND 0BSD AND MIT AND Zlib AND CC0-1.0compiled wheel · 3.12+
1.1Bdownloads / mo
fastapi Worth it
PyPI · Software Development · released Jul 2026

FastAPI is a Python web framework for building REST APIs using type hints, with automatic request validation, serialization, and interactive API documentation.

MITpure Python · 3.10+
568.6Mdownloads / mo
annotated-doc With conditions
PyPI · Software Development · released Jul 2026

Provides a way to document function parameters, class attributes, return types, and variables inline using Python's `Annotated` type hint syntax instead of traditional docstrings.

MITpure Python · 3.9+
456.2Mdownloads / mo
typer Worth it
PyPI · Software Development · released Aug 2026

Typer builds command-line applications from Python functions using type hints, automatically generating help text, argument parsing, and shell completion.

Install it if you are building CLIs in Python.

MITpure Python · 3.10+
369.3Mdownloads / mo
distlib With conditions
PyPI · Software Development · released Jun 2026

Distlib provides low-level packaging utilities for building, distributing, and managing Python software—including metadata handling, version specifiers, wheel support, script installation, and dependency resolution.

permissive licensepure Python
323.3Mdownloads / mo

See also pyfakefs · asyncmock · testfixtures · flexmock · pytest-mock · testpath · requests-file · mock · mocket · mockito