Skip to main content

Pytest Helpers Namespace Plugin

Project description

See Build Status Code Coverage PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported implementations

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:

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:

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:

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:

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.

Documentation

The full documentation can be seen here.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-helpers-namespace-2021.12.29.tar.gz (53.4 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page