pytest_notebook.utils module¶
Utility functions.
-
pytest_notebook.utils.
autodoc
(attrs_class)[source]¶ Decorate an
attr.s
class to update its docstring with attributes.The docstring will include the
attributes
, and emits warnings when partially undocumented attributes are found.If the class contains any attributes, they are documented as constructor parameters in a Parameters section, added at the end of the class’ docstring. In order to extract the most information per parameter description, this decorator assumes that every attribute
Typed (either via the
type
argument, or via PEP 526 type-annotations), andContains a metadata dictionary with the keys
- help:
The string that describes the attribute, and will go in the description of the corresponding parameter.
Default values are, of course, optional, and if provided, the parameter’s description will inform this. Private attributes will have their names rendered correctly (no leading underscore), and non-private attributes help-text will be complemented with a reminder that the parameter’s value can be later accessed via an attribute with that name.
Warning
Currently, there is no support for indicating that arguments are keyword-only, hashable, or validated. These and other exceptional conditions should be informed in the docstring.
-
pytest_notebook.utils.
running_as_test
()[source]¶ Check whether the notebook is being executed as a test.
This function may be useful, when running notebooks as integration tests to ensure the runtime is not exceedingly long.
Usage:
if not running_as_test(): output = call_very_long_process() else: output = "result"
See: https://docs.pytest.org/en/latest/example/simple.html#pytest-current-test-environment-variable