Skip to main content

Pytest Helpers Namespace

See Build Status on Travis CI See Build Status on AppVeyor Code Coverage PyPI Package latest release PyPI Package monthly downloads PyPI Wheel Supported versions Supported implementations

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:

pytest_plugins = ['helpers_namespace']

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.

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the Apache Software License 2.0 license, “pytest-helpers-namespace” is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Changelog

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

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

v2016.4.15

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

v2016.4.5

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

v2016.4.3

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

v2016.3.2

  • First working release


This Pytest plugin was generated with Cookiecutter along with @hackebrot’s Cookiecutter-pytest-plugin template.

Metadata

Release files for pytest-helpers-namespace 2019.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-helpers-namespace 2019.1.8
File Size Uploaded
pytest-helpers-namespace-2019.1.8.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-helpers-namespace 2019.1.8
File Interpreter ABI Platform
pytest_helpers_namespace-2019.1.8-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 20.6 kB

Release files / pytest-helpers-namespace-2019.1.8.tar.gz

Download URL pytest-helpers-namespace-2019.1.8.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4eff23a19f92410c0166f6dffbfa8901d3e14a80e97d70cd08428b6d597771ce
BLAKE2b-256 checksum
How to use checksums
935bae24cec4cb4f4590c4cde1e7914a152f4659351145dd7118563b8161f254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.8

Release files / pytest_helpers_namespace-2019.1.8-py2.py3-none-any.whl

Download URL pytest_helpers_namespace-2019.1.8-py2.py3-none-any.whl
Size 15.1 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e2c5475bc6d50e81a30f5644b1612ada643c81bfc8ca51efc1d08ebac299fb31
BLAKE2b-256 checksum
How to use checksums
1ef79a325e80cdf3da09e6c2d337ff1e004ffa377cbe1e48586fe13d9dafeffa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.6.8
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page