Skip to content

Commit 02bddcf

Browse files
committed
Minor documentation updates
- streamlined README - moved section about testing to documentation - mention conda install in documentation
1 parent 01e7b5c commit 02bddcf

File tree

2 files changed

+79
-113
lines changed

2 files changed

+79
-113
lines changed

README.md

Lines changed: 28 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,37 @@
11
# pyfakefs [![PyPI version](https://badge.fury.io/py/pyfakefs.svg)](https://badge.fury.io/py/pyfakefs) [![Python version](https://img.shields.io/pypi/pyversions/pyfakefs.svg)](https://img.shields.io/pypi/pyversions/pyfakefs.svg) ![Testsuite](https://github.com/pytest-dev/pyfakefs/workflows/Testsuite/badge.svg) [![Documentation Status](https://readthedocs.org/projects/pytest-pyfakefs/badge/?version=latest)](https://pytest-pyfakefs.readthedocs.io/en/latest/?badge=latest) [![pre-commit.ci status](https://results.pre-commit.ci/badge/github/pytest-dev/pyfakefs/main.svg)](https://results.pre-commit.ci/latest/github/pytest-dev/pyfakefs/main) ![PyPI - Downloads](https://img.shields.io/pypi/dw/pyfakefs)
22

33

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

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

13-
There are several means to achieve this: by using
14-
the `fs` fixture if running pytest, by using `fake_filesystem_unittest.TestCase` as a
15-
base class if using unittest, by using a `fake_filesystem_unittest.Patcher` instance
16-
as a context manager, or by using the `patchfs` decorator.
13+
`pyfakefs` is tested with current versions of Linux, Windows and macOS.
1714

15+
## Usage
1816

17+
There are several ways to invoke `pyfakefs`:
18+
* using the `fs` fixture with `pytest`
19+
* deriving from `fake_filesystem_unittest.TestCase` for `unittest`
20+
* using `fake_filesystem_unittest.Patcher` as context manager
21+
* using the `fake_filesystem_unittest.patchfs` decorator on a single test
1922

20-
pyfakefs works with current versions of Linux, Windows and macOS.
23+
Refer to the [usage documentation](https://pytest-pyfakefs.readthedocs.io/en/latest/usage.html) for more information.
2124

2225
## Documentation
2326

24-
This document provides a general overview for pyfakefs. There is more:
25-
26-
* The documentation at **Read the Docs**:
27-
* The [Release documentation](https://pytest-pyfakefs.readthedocs.io/en/stable)
28-
contains usage documentation for pyfakefs and a description of the
29-
most relevant classes, methods and functions for the last version
30-
released on PyPI
31-
* The [Development documentation](https://pytest-pyfakefs.readthedocs.io/en/latest)
32-
contains the same documentation for the current main branch
33-
* The [Release 3.7 documentation](https://pytest-pyfakefs.readthedocs.io/en/v3.7.2/)
34-
contains usage documentation for the last version of pyfakefs
35-
supporting Python 2.7
36-
* The [Release Notes](https://github.com/pytest-dev/pyfakefs/blob/main/CHANGES.md)
37-
show a list of changes in the latest versions
38-
39-
## Usage
40-
The simplest method to use pyfakefs is using the `fs` fixture with `pytest`.
41-
Refer to the
42-
[usage documentation](https://pytest-pyfakefs.readthedocs.io/en/latest/usage.html)
43-
for information on other test scenarios, test customization and
44-
using convenience functions.
27+
* [Release documentation](https://pytest-pyfakefs.readthedocs.io/en/stable)
28+
covers the latest released version
29+
* [Development documentation](https://pytest-pyfakefs.readthedocs.io/en/latest)
30+
for the current main branch
31+
* [Release 3.7 documentation](https://pytest-pyfakefs.readthedocs.io/en/v3.7.2/)
32+
for the last version supporting Python 2.7
33+
* [Release Notes](https://github.com/pytest-dev/pyfakefs/blob/main/CHANGES.md)
34+
* [Contributing Guide](https://github.com/pytest-dev/pyfakefs/blob/main/CONTRIBUTING.md) - contributions are welcome!
4535

4636
## Features
4737
Apart from automatically mocking most file-system functions, pyfakefs
@@ -54,86 +44,23 @@ provides some additional features:
5444
- configuration to behave as if running as a non-root user while running
5545
under root
5646

57-
## Compatibility
58-
pyfakefs works with CPython 3.7 and above, on Linux, Windows and macOS, and
59-
with PyPy3.
60-
61-
pyfakefs works with [pytest](http://doc.pytest.org) version 6.2.5 or above,
62-
though a current version is recommended.
63-
47+
## Limitations
6448
pyfakefs will not work with Python libraries that use C libraries to access the
6549
file system. This is because pyfakefs cannot patch the underlying C libraries'
6650
file access functions--the C libraries will always access the real file
67-
system. Refer to the
68-
[documentation](https://pytest-pyfakefs.readthedocs.io/en/latest/intro.html#limitations)
51+
system. Refer to the [documentation](https://pytest-pyfakefs.readthedocs.io/en/latest/intro.html#limitations)
6952
for more information about the limitations of pyfakefs.
7053

71-
## Development
72-
73-
### Continuous integration
74-
75-
pyfakefs is currently automatically tested on Linux, macOS and Windows, with
76-
Python 3.7 to 3.13, and with PyPy3 on Linux, using
77-
[GitHub Actions](https://github.com/pytest-dev/pyfakefs/actions).
78-
79-
### Running pyfakefs unit tests
80-
81-
#### On the command line
82-
pyfakefs unit tests can be run using `pytest` (all tests) or `unittest`
83-
(all tests except `pytest`-specific ones):
84-
85-
```bash
86-
$ cd pyfakefs/
87-
$ export PYTHONPATH=$PWD
88-
89-
$ python -m pytest pyfakefs
90-
$ python -m pyfakefs.tests.all_tests
91-
```
92-
93-
Similar scripts are called by `tox` and Github Actions. `tox` can be used to
94-
run tests locally against supported python versions:
95-
96-
```bash
97-
$ tox
98-
```
99-
100-
#### In a Docker container
101-
102-
The `Dockerfile` at the repository root will run the tests on the latest
103-
Ubuntu version. Build the container:
104-
```bash
105-
cd pyfakefs/
106-
docker build -t pyfakefs .
107-
```
108-
Run the unit tests in the container:
109-
```bash
110-
docker run -t pyfakefs
111-
```
112-
113-
### Contributing to pyfakefs
114-
115-
We always welcome contributions to the library. Check out the
116-
[Contributing Guide](https://github.com/pytest-dev/pyfakefs/blob/main/CONTRIBUTING.md)
117-
for more information.
118-
11954
## History
12055
pyfakefs.py was initially developed at Google by Mike Bland as a modest fake
12156
implementation of core Python modules. It was introduced to all of Google
122-
in September 2006. Since then, it has been enhanced to extend its
123-
functionality and usefulness. At last count, pyfakefs was used in over 20,000
57+
in September 2006. At last count, pyfakefs was used in over 20,000
12458
Python tests at Google.
12559

126-
Google released pyfakefs to the public in 2011 as Google Code project
127-
[pyfakefs](http://code.google.com/p/pyfakefs/):
128-
* Fork
129-
[jmcgeheeiv-pyfakefs](http://code.google.com/p/jmcgeheeiv-pyfakefs/) added
130-
[direct support for unittest and doctest](../../wiki/Automatically-find-and-patch-file-functions-and-modules)
131-
* Fork
132-
[shiffdane-jmcgeheeiv-pyfakefs](http://code.google.com/p/shiffdane-jmcgeheeiv-pyfakefs/)
133-
added further corrections
134-
135-
After the [shutdown of Google Code](http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html)
60+
Google released pyfakefs to the public in 2011 as a Google Code project.
61+
Support for `unittest` and `doctest` was added in a fork by user `jmcgeheeiv`,
62+
further corrections were made in a separate fork with user `shiffdane`, and after
63+
the [shutdown of Google Code](http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html)
13664
was announced, [John McGehee](https://github.com/jmcgeheeiv) merged all three Google Code projects together
137-
[here on GitHub](https://github.com/pytest-dev/pyfakefs) where an enthusiastic community actively supports, maintains
138-
and extends pyfakefs. In 2022, the repository has been transferred to
65+
[here on GitHub](https://github.com/pytest-dev/pyfakefs). In 2022, the repository has been transferred to
13966
[pytest-dev](https://github.com/pytest-dev) to ensure continuous maintenance.

docs/intro.rst

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@ providing the `fs` fixture that enables the fake filesystem.
1515
Installation
1616
------------
1717
``pyfakefs`` is available on `PyPI <https://pypi.python.org/pypi/pyfakefs/>`__.
18-
The latest released version can be installed from PyPI:
19-
20-
.. code:: bash
18+
The latest released version can be installed from PyPI::
2119

2220
pip install pyfakefs
2321

24-
The latest development version (main branch) can be installed from the GitHub sources:
22+
It is also available for `conda <https://docs.conda.io/>`_ at
23+
`conda-forge <https://anaconda.org/conda-forge/pyfakefs>`__::
24+
25+
conda install pyfakefs
2526

26-
.. code:: bash
27+
The latest development version (main branch) can be installed from the GitHub sources::
2728

2829
pip install git+https://github.com/pytest-dev/pyfakefs
2930

@@ -139,14 +140,10 @@ Google in September 2006. Since then, it has been enhanced to extend its
139140
functionality and usefulness. At last count, ``pyfakefs`` was used in over
140141
20,000 Python tests at Google.
141142

142-
Google released ``pyfakefs`` to the public in 2011 as Google Code project
143-
`pyfakefs <http://code.google.com/p/pyfakefs/>`__:
143+
Google released ``pyfakefs`` to the public in 2011 as a Google Code project.
144144

145-
* Fork `jmcgeheeiv-pyfakefs <http://code.google.com/p/jmcgeheeiv-pyfakefs/>`__
146-
added direct support for unittest and doctest as described in
147-
:ref:`auto_patch`
148-
* Fork `shiffdane-jmcgeheeiv-pyfakefs <http://code.google.com/p/shiffdane-jmcgeheeiv-pyfakefs/>`__
149-
added further corrections
145+
* the fork `jmcgeheeiv-pyfakefs` added direct support for unittest and doctest
146+
* the fork `shiffdane-jmcgeheeiv-pyfakefs` added further corrections
150147

151148
After the `shutdown of Google
152149
Code <http://google-opensource.blogspot.com/2015/03/farewell-to-google-code.html>`__
@@ -156,3 +153,45 @@ GitHub <https://github.com/pytest-dev/pyfakefs>`__ where an enthusiastic
156153
community actively maintains and extends pyfakefs. In 2022, the repository has
157154
been transferred to `pytest-dev <https://github.com/pytest-dev>`__ to ensure
158155
continuous maintenance.
156+
157+
158+
Running pyfakefs unit tests
159+
---------------------------
160+
161+
Continuous Integration
162+
......................
163+
164+
``pyfakefs`` is currently automatically tested on Linux, macOS and Windows, with
165+
Python 3.7 to 3.13, and with PyPy3 on Linux, using
166+
`GitHub Actions <https://github.com/pytest-dev/pyfakefs/actions>`__.
167+
168+
On the command line
169+
...................
170+
171+
``pyfakefs`` unit tests can be run using ``pytest`` (all tests) or ``unittest``
172+
(all tests except ``pytest``-specific ones)::
173+
174+
$ cd pyfakefs/
175+
$ export PYTHONPATH=$PWD
176+
177+
$ python -m pytest pyfakefs
178+
$ python -m pyfakefs.tests.all_tests
179+
180+
Similar scripts are called by ``tox`` and Github Actions. ``tox`` can be used to
181+
run tests locally against supported python versions::
182+
183+
$ tox
184+
185+
186+
In a docker container
187+
.....................
188+
189+
The ``Dockerfile`` at the repository root will run the tests on the latest
190+
Ubuntu version. Build the container::
191+
192+
cd pyfakefs/
193+
docker build -t pyfakefs .
194+
195+
Run the unit tests in the container::
196+
197+
docker run -t pyfakefs

0 commit comments

Comments
 (0)