Skip to main content

PyTest Helpers Namespace

Project description

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

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

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.

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-2016.7.10.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

pytest_helpers_namespace-2016.7.10-py2.py3-none-any.whl (7.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pytest-helpers-namespace-2016.7.10.tar.gz.

File metadata

File hashes

Hashes for pytest-helpers-namespace-2016.7.10.tar.gz
Algorithm Hash digest
SHA256 d8bdb017c0f7271699c08850b6b12e1ce9e52913cbd4461b5febd21082a29113
MD5 80fe3e515f640b1459709b539f6b857e
BLAKE2b-256 c85578a8bafce267241b72e058d6d1b7e183396b61818a8634da54d27188d48b

See more details on using hashes here.

File details

Details for the file pytest_helpers_namespace-2016.7.10-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_helpers_namespace-2016.7.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4ada2d4d277dea7e00805a0958554b7c4686868acddc46257834e8d137f0552f
MD5 88e8376c8a38009432ade3eb38741ea8
BLAKE2b-256 a132329ca957ef701a678aa88ef2ed1b228ecb3eec0c8799a489d436bab0f36f

See more details on using hashes here.

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