diff options
author | mrbean-bremen <hansemrbean@googlemail.com> | 2020-03-02 19:14:53 +0100 |
---|---|---|
committer | mrbean-bremen <hansemrbean@googlemail.com> | 2020-03-02 19:14:53 +0100 |
commit | 3ca076766539c6777fb431bdf6c0c516583dcb66 (patch) | |
tree | 77948873feb5f5e869e9e9daec43e1f4ac9c0b7d | |
parent | 4afa338179743c95e86ee6a52a92e1520e671de8 (diff) | |
download | pyfakefs-3ca076766539c6777fb431bdf6c0c516583dcb66.tar.gz |
Added more examples for patchfs decorator
- fixed error in documentation code example
-rw-r--r-- | docs/usage.rst | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/docs/usage.rst b/docs/usage.rst index adf4686..cd9a9cd 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -250,11 +250,18 @@ Given that the example code shown above is located in the file # example using Patcher def test_path_exists(): - with Patcher() as patcher: + with Patcher(modules_to_reload=[example.sut]) as patcher: file_path = '/foo/bar' patcher.fs.create_dir(file_path) assert example.sut.check_if_exists(file_path) + # example using patchfs decorator + @patchfs(modules_to_reload=[example.sut]) + def test_path_exists(fs): + file_path = '/foo/bar' + fs.create_dir(file_path) + assert example.sut.check_if_exists(file_path) + modules_to_patch ~~~~~~~~~~~~~~~~ @@ -311,6 +318,11 @@ fake a module in Django that uses OS file system functions: def test_django_stuff(fs): ... + # test code using patchfs decorator + @patchfs(modules_to_patch={'django.core.files.locks': FakeLocks}) + def test_django_stuff(fs): + ... + additional_skip_names ~~~~~~~~~~~~~~~~~~~~~ This may be used to add modules that shall not be patched. This is mostly |