Apache License 2.0

项目介绍

pytest-dev/pyfakefs 是一个托管在 GitHub 上的开源项目,主要使用 Python 编写,采用 Apache License 2.0 许可证,目前获得 757 个 Star、112 次 Fork。

仓库全名
pytest-dev/pyfakefs
开源许可证
Apache License 2.0
Star 数
757
Fork 数
112
未关闭 Issue
19

README 摘要

pyfakefs implements a fake file system that mocks the Python file system modules. Using pyfakefs, your tests operate on a fake file system in memory without touching the real disk. The software under test requires no modification to work with pyfakefs. pyfakefs creates a new empty in-memory file system at each test start, which replaces the real filesystem during the test. Think of pyfakefs as making a per-test…

完整内容见 GitHub 原始 README 或本页 。

常见问题

pyfakefs 用什么语言开发?

主要使用 Python 编写,采用 Apache License 2.0 许可证,目前有 757 个 Star。

pyfakefs 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 pyfakefs 的源码?

可以直接克隆仓库:git clone https://github.com/pytest-dev/pyfakefs.git,默认分支为 main;安装与运行步骤见仓库 README。

pyfakefs 最近还在维护吗?

仓库最近一次更新为 2 天前,当前有 19 个未关闭 Issue;Star 数为 757,可作为社区活跃度的参考。

关于

GitHub 原始描述(英文)

Provides a fake file system that mocks the Python file system modules.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

简要分析

热度分
990
价值分
487
活跃状态
活跃

语言占比

Dockerfile
Python

README

pyfakefs PyPI version Python version Testsuite Documentation Status pre-commit.ci status PyPI - Downloads

pyfakefs implements a fake file system that mocks the Python file system modules. Using pyfakefs, your tests operate on a fake file system in memory without touching the real disk. The software under test requires no modification to work with pyfakefs.

pyfakefs creates a new empty in-memory file system at each test start, which replaces the real filesystem during the test. Think of pyfakefs as making a per-test temporary directory, except for an entire file system.

pyfakefs is tested with current versions of Linux, Windows and macOS.

Usage

There are several ways to invoke pyfakefs:

  • using the fs fixture with pytest
  • deriving from fake_filesystem_unittest.TestCase for unittest
  • using fake_filesystem_unittest.Patcher as context manager
  • using the fake_filesystem_unittest.patchfs decorator on a single test

Refer to the usage documentation for more information.

Documentation

Features

Apart from automatically mocking most file-system functions, pyfakefs provides some additional features:

  • mapping files and directories from the real file system into the fake filesystem
  • configuration and tracking of the file system size
  • pause and resume of patching to be able to use the real file system inside a test step
  • (limited) emulation of other OSes (Linux, macOS or Windows)
  • configuration to behave as if running as a non-root user while running under root

Limitations

pyfakefs will not work with Python libraries that use C libraries to access the file system. This is because pyfakefs cannot patch the underlying C libraries’ file access functions–the C libraries will always access the real file system. Refer to the documentation for more information about the limitations of pyfakefs.

History

pyfakefs.py was initially developed at Google by Mike Bland as a modest fake implementation of core Python modules. It was introduced to all of Google in September 2006. At last count, pyfakefs was used in over 20,000 Python tests at Google.

Google released pyfakefs to the public in 2011 as a Google Code project. Support for unittest and doctest was added in a fork by user jmcgeheeiv, further corrections were made in a separate fork with user shiffdane, and after the shutdown of Google Code was announced, John McGehee merged all three Google Code projects together here on GitHub. In 2022, the repository has been transferred to pytest-dev to ensure continuous maintenance.

评论

暂无评论