Skip to content

Commit 14eab82

Browse files
committed
Minor documentation changes
1 parent f7a8f6d commit 14eab82

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ You can contribute to:
4848
* the source code documentation using [Google documentation style](https://google.github.io/styleguide/pyguide.html)
4949
* the [README](https://github.com/jmcgeheeiv/pyfakefs/blob/master/README.md) using [markdown syntax](https://help.github.com/articles/basic-writing-and-formatting-syntax/)
5050
* the documentation published on [GitHub Pages](http://jmcgeheeiv.github.io/pyfakefs/),
51-
located in the `docs` directory.
51+
located in the `docs` directory (call `make html` from that directory).
5252
For building the documentation, you will need [sphinx](http://sphinx.pocoo.org/).
5353
* [this file](https://github.com/jmcgeheeiv/pyfakefs/blob/master/CONTRIBUTING.md)
5454
if you want to enhance the contributing guide itself

docs/intro.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ Features
4747
- pyfakefs keeps track of the filesystem size if configured. The file system
4848
size can be configured arbitrarily.
4949

50+
- it is possible to pause and resume using the fake filesystem, if the
51+
real file system has to be used in a test step
52+
5053
- pyfakefs defaults to the OS it is running on, but can also be configured
5154
to test code running under another OS (Linux, MacOS or Windows).
5255

5356
- pyfakefs can be configured to behave as if running as a root or as a
5457
non-root user, independently from the actual user.
5558

59+
.. _limitations:
5660

5761
Limitations
5862
-----------
5963
- pyfakefs will not work with Python libraries (other than `os` and `io`) that
6064
use C libraries to access the file system, because it cannot patch the
61-
underlying C libraries' file access functions.
65+
underlying C libraries' file access functions
6266

6367
- pyfakefs patches most kinds of importing file system modules automatically,
6468
but there are still some cases where this will not work.
@@ -70,15 +74,16 @@ Limitations
7074
between binary and textual file objects).
7175

7276
- pyfakefs is only tested with CPython and the newest PyPy versions, other
73-
Python implementations will probably not work.
77+
Python implementations will probably not work
7478

7579
- Differences in the behavior in different Linux distributions or different
7680
MacOS or Windows versions may not be reflected in the implementation, as
7781
well as some OS-specific low-level file system behavior. The systems used
7882
for automatic tests in
7983
`Travis.CI <https://travis-ci.org/jmcgeheeiv/pyfakefs>`__ and
8084
`AppVeyor <https://ci.appveyor.com/project/jmcgeheeiv/pyfakefs>`__ are
81-
considered as reference systems.
85+
considered as reference systems, additionally the tests are run in Docker
86+
containers with the latest CentOS, Debian, Fedora and Ubuntu images.
8287

8388
History
8489
-------

docs/usage.rst

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ The PyTest plugin provides the ``fs`` fixture for use in your test. For example:
5050
Patch using fake_filesystem_unittest.Patcher
5151
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5252
If you are using other means of testing like `nose <http://nose2.readthedocs.io>`__, you can do the
53-
patching using ``fake_filesystem_unittest.Patcher`` - the class doing the actual work
53+
patching using ``fake_filesystem_unittest.Patcher``--the class doing the
54+
actual work
5455
of replacing the filesystem modules with the fake modules in the first two approaches.
5556

5657
The easiest way is to just use ``Patcher`` as a context manager:
@@ -363,18 +364,19 @@ Some libraries are known to require patching in order to work with pyfakefs.
363364
If ``use_known_patches`` is set to ``True`` (the default), pyfakefs patches
364365
these libraries so that they will work with the fake filesystem. Currently, this
365366
includes patches for ``pandas`` read methods like ``read_csv`` and
366-
``read_excel``--more may follow. Ordinarily, the default value of
367-
``use_known_patches`` should be used, but it is present to allow users to
368-
disable this patching in case it causes any problems. It may be removed or
369-
replaced by more fine-grained arguments in future releases.
367+
``read_excel``, and for ``Django`` file locks--more may follow. Ordinarily,
368+
the default value of ``use_known_patches`` should be used, but it is present
369+
to allow users to disable this patching in case it causes any problems. It
370+
may be removed or replaced by more fine-grained arguments in future releases.
370371

371372
Using convenience methods
372373
-------------------------
373374
While ``pyfakefs`` can be used just with the standard Python file system
374375
functions, there are few convenience methods in ``fake_filesystem`` that can
375376
help you setting up your tests. The methods can be accessed via the
376377
``fake_filesystem`` instance in your tests: ``Patcher.fs``, the ``fs``
377-
fixture in PyTest, or ``TestCase.fs``.
378+
fixture in PyTest, ``TestCase.fs`` for ``unittest``, and the ``fs`` argument
379+
for the ``patchfs`` decorator.
378380

379381
File creation helpers
380382
~~~~~~~~~~~~~~~~~~~~~
@@ -384,7 +386,7 @@ in the path, you may use ``create_file()``, ``create_dir()`` and
384386

385387
``create_file()`` also allows you to set the file mode and the file contents
386388
together with the encoding if needed. Alternatively, you can define a file
387-
size without contents - in this case, you will not be able to perform
389+
size without contents--in this case, you will not be able to perform
388390
standard I\O operations on the file (may be used to "fill up" the file system
389391
with large files).
390392

@@ -502,8 +504,9 @@ testing cleanup scripts), you can set the fake file system size using
502504
root partition; if you add a path as parameter, the size will be related to
503505
the mount point (see above) the path is related to.
504506
505-
By default, the size of the fake file system is considered infinite. As soon
506-
as you set a size, all files will occupy the space according to their size,
507+
By default, the size of the fake file system is set to 1 TB (which
508+
for most tests can be considered as infinite). As soon as you set a
509+
size, all files will occupy the space according to their size,
507510
and you may fail to create new files if the fake file system is full.
508511
509512
.. code:: python
@@ -600,9 +603,10 @@ reasons:
600603
libraries. These will not work out of the box, and we generally will not
601604
support them in ``pyfakefs``. If these functions are used in isolated
602605
functions or classes, they may be patched by using the ``modules_to_patch``
603-
parameter (see the example for file locks in Django above), and if there
604-
are more examples for patches that may be useful, we may add them in the
605-
documentation.
606+
parameter (see the example for file locks in Django above). We may add
607+
some of these patches to ``pyfakefs``, so that they are applied
608+
automatically (currently done for some ``pandas`` and ``Django``
609+
functionality).
606610
- It uses C libraries to access the file system. There is no way no make
607611
such a module work with ``pyfakefs``--if you want to use it, you
608612
have to patch the whole module. In some cases, a library implemented in
@@ -615,6 +619,11 @@ A list of Python modules that are known to not work correctly with
615619
- ``multiprocessing`` has several issues (related to points 1 and 3 above).
616620
Currently there are no plans to fix this, but this may change in case of
617621
sufficient demand.
622+
- ``subprocess`` has very similar problems and cannot be used with
623+
``pyfakefs`` to start a process. ``subprocess`` can either be mocked, if
624+
the process is not needed for the test, or patching can be paused to start
625+
a process if needed, and resumed afterwards
626+
(see `this issue <https://github.com/jmcgeheeiv/pyfakefs/issues/447>`__).
618627
- the ``Pillow`` image library does not work with pyfakefs at least if writing
619628
JPEG files (see `this issue <https://github.com/jmcgeheeiv/pyfakefs/issues/529>`__)
620629
- ``pandas`` (the Python data analysis library) uses its own internal file
@@ -627,6 +636,16 @@ A list of Python modules that are known to not work correctly with
627636
If you are not sure if a module can be handled, or how to do it, you can
628637
always write a new issue, of course!
629638
639+
Pyfakefs behaves differently than the real filesystem
640+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
641+
There are basically two kinds of deviations from the actual behavior:
642+
643+
- unwanted deviations that we didn't notice--if you find any of these, please
644+
write an issue and will try to fix it
645+
- behavior that depends on different OS versions and editions--as mentioned
646+
in :ref:`limitations`, pyfakefs uses the TravisCI systems as reference
647+
system and will not replicate all system-specific behavior
648+
630649
OS temporary directories
631650
~~~~~~~~~~~~~~~~~~~~~~~~
632651
@@ -642,13 +661,13 @@ directory named ``/tmp`` when running on Linux or Unix systems,
642661
User rights
643662
~~~~~~~~~~~
644663
645-
If you run pyfakefs tests as root (this happens by default if run in a
646-
docker container), pyfakefs also behaves as a root user, for example can
664+
If you run ``pyfakefs`` tests as root (this happens by default if run in a
665+
docker container), ``pyfakefs`` also behaves as a root user, for example can
647666
write to write-protected files. This may not be the expected behavior, and
648667
can be changed.
649-
Pyfakefs has a rudimentary concept of user rights, which differentiates
668+
``Pyfakefs`` has a rudimentary concept of user rights, which differentiates
650669
between root user (with the user id 0) and any other user. By default,
651-
pyfakefs assumes the user id of the current user, but you can change
670+
``pyfakefs`` assumes the user id of the current user, but you can change
652671
that using ``fake_filesystem.set_uid()`` in your setup. This allows to run
653672
tests as non-root user in a root user environment and vice verse.
654673
Another possibility is the convenience argument ``allow_root_user``

0 commit comments

Comments
 (0)