-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #24
- Loading branch information
Showing
19 changed files
with
478 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:mod:`logot.trio` | ||
================= | ||
|
||
.. automodule:: logot.trio | ||
|
||
|
||
API reference | ||
------------- | ||
|
||
.. autoclass:: TrioWaiter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. currentmodule:: logot | ||
|
||
.. note:: | ||
|
||
Use the ``timeout`` argument to :meth:`Logot.await_for` to configure how long to wait before the test fails. This can | ||
be configured globally with the ``timeout`` argument to :class:`Logot`, defaulting to :attr:`Logot.DEFAULT_TIMEOUT`. | ||
|
||
.. seealso:: | ||
|
||
See :doc:`/log-pattern-matching` for examples of how to wait for logs that may arrive in an unpredictable order. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
3rd-party integrations | ||
====================== | ||
|
||
.. currentmodule:: logot | ||
|
||
:mod:`logot` integrates with a number of 3rd-party frameworks to extend its functionality. | ||
|
||
.. note:: | ||
|
||
Adding support for additional 3rd-party frameworks is an excellent way of | ||
`contributing <https://github.com/etianen/logot/blob/main/CONTRIBUTING.md>`_ to :mod:`logot`! 🙇 | ||
|
||
|
||
.. _integrations-async: | ||
|
||
Asynchronous frameworks | ||
----------------------- | ||
|
||
Integrations with 3rd-party asynchronous frameworks extend :meth:`Logot.await_for`, allowing you to | ||
:ref:`test asynchronous code <index-testing-async>` using your framework of choice. 💪 | ||
|
||
Learn about supported 3rd-party asynchronous frameworks: | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
trio | ||
|
||
.. seealso:: | ||
|
||
See :ref:`index-testing-async` usage guide. | ||
|
||
See :class:`AsyncWaiter` API reference for integrating with 3rd-party asynchronous frameworks. | ||
|
||
|
||
.. _integrations-logging: | ||
|
||
Logging frameworks | ||
------------------ | ||
|
||
Integrations with 3rd-party logging frameworks extend :meth:`Logot.capturing`, allowing you to | ||
:doc:`capture logs </log-capturing>` using your framework of choice. 💪 | ||
|
||
Learn about supported 3rd-party logging frameworks: | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
.. seealso:: | ||
|
||
See :doc:`/log-capturing` usage guide. | ||
|
||
See :class:`Capturer` API reference for integrating with 3rd-party logging frameworks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
Using with :mod:`trio` | ||
====================== | ||
|
||
.. currentmodule:: logot | ||
|
||
Use :meth:`Logot.await_for` to pause your test until the expected logs arrive or the ``timeout`` expires: | ||
|
||
.. code:: python | ||
from logot import Logot, logged | ||
async def test_app(logot: Logot) -> None: | ||
async with trio.open_nursery() as nursery: | ||
nursery.start_soon(app.start()) | ||
await logot.await_for(logged.info("App started")) | ||
.. include:: /include/testing-async-notes.rst | ||
|
||
|
||
Installing | ||
---------- | ||
|
||
Ensure :mod:`logot` is installed alongside a compatible :mod:`trio` version by adding the ``trio`` extra: | ||
|
||
.. code:: bash | ||
pip install 'logot[trio]' | ||
.. seealso:: | ||
|
||
See :ref:`installing-extras` usage guide. | ||
|
||
|
||
Enabling for :mod:`pytest` | ||
-------------------------- | ||
|
||
Enable :mod:`trio` support in your :external+pytest:doc:`pytest configuration <reference/customize>`: | ||
|
||
.. code:: ini | ||
# pytest.ini or .pytest.ini | ||
[pytest] | ||
logot_async_waiter = logot.trio.TrioWaiter | ||
.. code:: toml | ||
# pyproject.toml | ||
[tool.pytest.ini_options] | ||
logot_async_waiter = "logot.trio.TrioWaiter" | ||
.. seealso:: | ||
|
||
See :doc:`/using-pytest` usage guide. | ||
|
||
|
||
Enabling for :mod:`unittest` | ||
---------------------------- | ||
|
||
Enable :mod:`trio` support in your :class:`logot.unittest.LogotTestCase`: | ||
|
||
.. code:: python | ||
from logot.trio import TrioWaiter | ||
class MyAppTest(LogotTestCase): | ||
logot_async_waiter = TrioWaiter | ||
.. seealso:: | ||
|
||
See :doc:`/using-unittest` usage guide. | ||
|
||
|
||
Enabling manually | ||
----------------- | ||
|
||
Enable :mod:`trio` support for your :class:`Logot` instance: | ||
|
||
.. code:: python | ||
from logot.trio import TrioWaiter | ||
logot = Logot(async_waiter=TrioWaiter) | ||
Enable :mod:`trio` support for a single :meth:`Logot.await_for` call: | ||
|
||
.. code:: python | ||
await logot.await_for(logged.info("App started"), async_waiter=TrioWaiter) | ||
.. seealso:: | ||
|
||
See :class:`Logot` and :meth:`Logot.await_for` API reference. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.