PyTest Helpers Namespace
Project description
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
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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-helpers-namespace-2017.11.11.tar.gz
.
File metadata
- Download URL: pytest-helpers-namespace-2017.11.11.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e866a0e75fd642a481fa5a9d279d309782dc40a50e383a5250c6e34c9950a46 |
|
MD5 | 315a22285097be77504af4f12944dd75 |
|
BLAKE2b-256 | 3a4620a6846dfa9dca48ae8c1f48b6a866df4efa7d4c858d19ca63bc59ceaaf5 |
File details
Details for the file pytest_helpers_namespace-2017.11.11-py2.py3-none-any.whl
.
File metadata
- Download URL: pytest_helpers_namespace-2017.11.11-py2.py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1add2b5081457d49c90e015fdea7d2d155322616881a1fe417ffa833a7562e4e |
|
MD5 | 7c1f9289d6b7c93555f94c47f3e4097d |
|
BLAKE2b-256 | 6ebe9f5823836d9191b03a25ba82b2cf085bd710e1bdf33b94bc7bda524d84d5 |