diff options
author | Stephen Finucane <stephen@that.guru> | 2023-03-31 10:56:58 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2023-03-31 11:05:28 +0100 |
commit | 3caef1b164b6e41a2d948475948e961211ad2ac1 (patch) | |
tree | 52911680b60d2ac39edd71dd04d1e7b41e574bdb | |
parent | 78d9fd053dcd40c0dffa1fee8a86c5bd384b9ccc (diff) | |
download | fixtures-git-3caef1b164b6e41a2d948475948e961211ad2ac1.tar.gz |
README: Document missing fixtures
Signed-off-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | README.rst | 48 |
1 files changed, 48 insertions, 0 deletions
@@ -351,6 +351,17 @@ tests:: >>> from io import BytesIO >>> fixture = fixtures.FakePopen(lambda _:{'stdout': BytesIO('foobar')}) +``LogHandler`` +++++++++++++++ + +Replace or extend a logger's handlers. The behavior of this fixture depends on +the value of the ``nuke_handlers`` parameter: if ``true``, the logger's +existing handlers are removed and replaced by the provided handler, while if +``false`` the logger's set of handlers is extended by the provided handler:: + + >>> from logging import StreamHandler + >>> fixture = fixtures.LogHandler(StreamHandler()) + ``MockPatchObject`` +++++++++++++++++++ @@ -429,6 +440,15 @@ path, nothing happens, if it isn't then it is added on ``setUp`` and removed on >>> fixture = fixtures.PythonPathEntry('/foo/bar') +``Stream`` +++++++++++ + +Trivial adapter to expose a file-like object as a detail object, for automatic +inclusion in test failure descriptions. ``StringStream`` and ``BytesStream`` +provided concrete users of this fixture. + +This requires the ``fixtures[streams]`` extra. + ``StringStream`` ++++++++++++++++ @@ -488,6 +508,34 @@ but more likely to break hangs where no Python code is running. > Currently supported only on Unix because it relies on the ``alarm`` system > call. +``WarningsCapture`` ++++++++++++++++++++ + +Capture warnings for later analysis:: + + >>> fixture = fixtures.WarningsCapture() + +The captured warnings are stored in the ``captures`` attribute of the fixture +after ``setUp``. + +``WarningsFilter`` +++++++++++++++++++ + +Configure warnings filters during test runs:: + + >>> fixture = fixtures.WarningsFilter( + ... [ + ... { + ... 'action': 'ignore', + ... 'message': 'foo', + ... 'category': DeprecationWarning, + ... }, + ... ] + ... ) + +Order is important: entries closer to the front of the list override entries +later in the list, if both match a particular warning. + Contributing ============ |