Socket
Socket
Sign inDemoInstall

pytest-helpers-namespace

Package Overview
Dependencies
12
Maintainers
3
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pytest-helpers-namespace

Pytest Helpers Namespace Plugin


Maintainers
3

Readme

.. image:: https://github.com/saltstack/pytest-helpers-namespace/actions/workflows/testing.yml/badge.svg :target: https://github.com/saltstack/pytest-helpers-namespace/actions/workflows/testing.yml :alt: See Build Status

.. image:: https://codecov.io/github/saltstack/pytest-helpers-namespace/coverage.svg?branch=master :target: https://codecov.io/github/saltstack/pytest-helpers-namespace?branch=master :alt: Code Coverage

.. image:: https://img.shields.io/pypi/v/pytest-helpers-namespace.svg?style=flat :alt: PyPI Package latest release :target: https://pypi.python.org/pypi/pytest-helpers-namespace

.. image:: https://img.shields.io/pypi/dm/pytest-helpers-namespace.svg?style=flat :alt: PyPI Package monthly downloads :target: https://pypi.python.org/pypi/pytest-helpers-namespace

.. image:: https://img.shields.io/pypi/wheel/pytest-helpers-namespace.svg?style=flat :alt: PyPI Wheel :target: https://pypi.python.org/pypi/pytest-helpers-namespace

.. image:: https://img.shields.io/pypi/pyversions/pytest-helpers-namespace.svg?style=flat :alt: Supported versions :target: https://pypi.python.org/pypi/pytest-helpers-namespace

.. image:: https://img.shields.io/pypi/implementation/pytest-helpers-namespace.svg?style=flat :alt: Supported implementations :target: https://pypi.python.org/pypi/pytest-helpers-namespace

.. include-starts-here

Pytest Helpers Namespace

This plugin does not provide any helpers to pytest, it does, however, provide a helpers namespace in pytest which enables you to register helper functions in your conftest.py to be used within your tests without having to import them.

Features

  • Provides a helpers pytest_ namespace which can be used to register helper functions without requiring you to import them on your actual tests to use them.

Requirements

  • None!

Installation

You can install "pytest-helpers-namespace" via pip_ from PyPI_::

$ pip install pytest-helpers-namespace

Usage

Consider the following conftest.py file:

.. code-block:: python

import pytest

@pytest.helpers.register def foo(bar): """ this dumb helper function will just return what you pass to it """ return bar

And now consider the following test case:

.. code-block:: python

def test_helper_namespace(): assert pytest.helpers.foo(True) is True

Pretty simple right?!

You can even nest namespaces. Consider the following conftest.py file:

.. code-block:: python

pytest_plugins = ["helpers_namespace"]

import pytest

@pytest.helpers.can.haz.register def foo(bar): """ this dumb helper function will just return what you pass to it """ return bar

And now consider the following test case:

.. code-block:: python

def test_helper_namespace(): assert pytest.helpers.can.haz.foo(True) is True

You can even pass a name to the register function and that will be the helper function name.


This Pytest_ plugin was generated with Cookiecutter_ along with @hackebrot's Cookiecutter-pytest-plugin template.

.. _Cookiecutter: https://github.com/audreyr/cookiecutter .. _@hackebrot: https://github.com/hackebrot .. _cookiecutter-pytest-plugin: https://github.com/pytest-dev/cookiecutter-pytest-plugin .. _pytest: https://github.com/pytest-dev/pytest .. _pip: https://pypi.python.org/pypi/pip/ .. _PyPI: https://pypi.python.org/pypi

.. include-ends-here

Documentation

The full documentation can be seen here <https://pytest-helpers-namespace.readthedocs.io>_.

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc