Pytest Helpers Namespace Plugin
Project description
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
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-2021.12.29.tar.gz
.
File metadata
- Download URL: pytest-helpers-namespace-2021.12.29.tar.gz
- Upload date:
- Size: 53.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/3.7.3 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 792038247e0021beb966a7ea6e3a70ff5fcfba77eb72c6ec8fd6287af871c35b |
|
MD5 | 8c12522bb08cdb9151f6e39d309d9483 |
|
BLAKE2b-256 | e8617f1a476b375c1238d152c164f7ffb694c662da8247816947be84b5fe2e8a |
File details
Details for the file pytest_helpers_namespace-2021.12.29-py3-none-any.whl
.
File metadata
- Download URL: pytest_helpers_namespace-2021.12.29-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/3.7.3 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5c0262642998437a73d85cb6ae0db57d574facc551c4a4695e92ec50469eb98 |
|
MD5 | 669b3ffba64d82e986b86e1550a6ebf0 |
|
BLAKE2b-256 | 63a734844a563c425962658f093b359636deefd19eab6783896e0d378dae88a1 |