Table Of Contents

pytest_helpers_namespace package

Submodules

pytest_helpers_namespace.plugin module

Pytest Helpers Namespace Plugin.

class pytest_helpers_namespace.plugin.FuncWrapper(func: pytest_helpers_namespace.plugin.F)[source]

Bases: object

Wrapper class for helper functions and namespaces.

static register(func: pytest_helpers_namespace.plugin.F) pytest_helpers_namespace.plugin.F[source]

Register a helper function.

This function will just raise a RuntimeError in case a function registration, which also sets a nested namespace, tries to override a known helper function with that nested namespace. This will just make the raised error make more sense.

Instead of “AttributeError: ‘function’ object has no attribute ‘register’”, we will raise the exception below.

__call__(*args: Any, **kwargs: Any) Any[source]

This wrapper will just call the actual helper function.

class pytest_helpers_namespace.plugin.HelpersRegistry[source]

Bases: object

Helper functions registrar which supports namespaces.

register(func: Union[pytest_helpers_namespace.plugin.F, str], name: Optional[str] = None) pytest_helpers_namespace.plugin.F[source]

Register’s a new function as a helper.

__getattribute__(name: str) Any[source]

Return an attribute from the registry or register a new namespace.

__repr__() str[source]

Return a string representation of the class.

__call__(*_: Any, **__: Any) Any[source]

Show a warning when calling an unregistered helper function.

__contains__(key: str) bool[source]

Check for the presence of a helper name in the registry.

pytest_helpers_namespace.plugin.pytest_load_initial_conftests(*_: Any) None[source]

Hook into pytest to inject our custom helpers registry.

pytest_helpers_namespace.plugin.pytest_sessionstart(session: Session) None[source]

Register our plugin with pytest.

pytest_helpers_namespace.plugin.pytest_unconfigure() None[source]

Delete our custom helpers registry from the pytest module namespace.

pytest_helpers_namespace.version module

Changelog

Versions follow Calendar Versioning (<year>.<month>.<day>).

[UNRELEASED DRAFT]

No significant changes.

2021.12.29

Improvements

  • #11: Plugin is now fully typed.

v2021.3.24

  • Switched project to a src layout.

  • Switched project to a declarative setuptools approach

  • Added support to check if a helper has been registered

  • Pytest >= 6.1.1 is now required

v2019.1.8

  • Patch PyTest before any conftest.py file is processed.

v2019.1.7

  • Support PyTest >= 4.1

v2019.1.6.post1

  • No changes were made besides locking to PyTest < 4.0

v2019.1.6

  • No changes were made besides locking to PyTest < 4.1

v2017.11.11

  • Allow passing a string to the register function which will be the helper name

v2016.7.10

  • #4: Allow a registered function to contibue to behave as a regular function.

v2016.4.15

  • #3: Hide the FuncWrapper traceback in pytest failures. Thanks Logan Glickfield(@lsglick)

v2016.4.5

  • Use a wrapper class instead of adding an attribute to a function.

v2016.4.3

  • #1: Provide proper errors when helper functions or namespaces are being overridden.

v2016.3.2

  • First working release