| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: pytest-helpers-namespace |
| 3 |
Version: 2021.4.29 |
| 4 |
Summary: Pytest Helpers Namespace Plugin |
| 5 |
Home-page: https://github.com/saltstack/pytest-helpers-namespace |
| 6 |
Author: Pedro Algarvio |
| 7 |
Author-email: [email protected] |
| 8 |
License: Apache Software License 2.0 |
| 9 |
Project-URL: Source, https://github.com/saltstack/pytest-helpers-namespace |
| 10 |
Project-URL: Tracker, https://github.com/saltstack/pytest-helpers-namespace/issues |
| 11 |
Project-URL: Documentation, https://pytest-helpers-namespace.readthedocs.io |
| 12 |
Description: .. image:: https://github.com/saltstack/pytest-helpers-namespace/actions/workflows/testing.yml/badge.svg |
| 13 |
:target: https://github.com/saltstack/pytest-helpers-namespace/actions/workflows/testing.yml |
| 14 |
:alt: See Build Status |
| 15 |
|
| 16 |
.. image:: https://codecov.io/github/saltstack/pytest-helpers-namespace/coverage.svg?branch=master |
| 17 |
:target: https://codecov.io/github/saltstack/pytest-helpers-namespace?branch=master |
| 18 |
:alt: Code Coverage |
| 19 |
|
| 20 |
.. image:: https://img.shields.io/pypi/v/pytest-helpers-namespace.svg?style=flat |
| 21 |
:alt: PyPI Package latest release |
| 22 |
:target: https://pypi.python.org/pypi/pytest-helpers-namespace |
| 23 |
|
| 24 |
.. image:: https://img.shields.io/pypi/dm/pytest-helpers-namespace.svg?style=flat |
| 25 |
:alt: PyPI Package monthly downloads |
| 26 |
:target: https://pypi.python.org/pypi/pytest-helpers-namespace |
| 27 |
|
| 28 |
.. image:: https://img.shields.io/pypi/wheel/pytest-helpers-namespace.svg?style=flat |
| 29 |
:alt: PyPI Wheel |
| 30 |
:target: https://pypi.python.org/pypi/pytest-helpers-namespace |
| 31 |
|
| 32 |
.. image:: https://img.shields.io/pypi/pyversions/pytest-helpers-namespace.svg?style=flat |
| 33 |
:alt: Supported versions |
| 34 |
:target: https://pypi.python.org/pypi/pytest-helpers-namespace |
| 35 |
|
| 36 |
.. image:: https://img.shields.io/pypi/implementation/pytest-helpers-namespace.svg?style=flat |
| 37 |
:alt: Supported implementations |
| 38 |
:target: https://pypi.python.org/pypi/pytest-helpers-namespace |
| 39 |
|
| 40 |
|
| 41 |
Pytest Helpers Namespace |
| 42 |
======================== |
| 43 |
|
| 44 |
This plugin does not provide any helpers to `pytest`_, it does, however, |
| 45 |
provide a helpers namespace in `pytest`_ which enables you to register helper |
| 46 |
functions in your ``conftest.py`` to be used within your tests without having |
| 47 |
to import them. |
| 48 |
|
| 49 |
|
| 50 |
Features |
| 51 |
-------- |
| 52 |
|
| 53 |
* Provides a ``helpers`` `pytest`_ namespace which can be used to register |
| 54 |
helper functions without requiring you to import them on your actual tests to |
| 55 |
use them. |
| 56 |
|
| 57 |
|
| 58 |
Requirements |
| 59 |
------------ |
| 60 |
|
| 61 |
* None! |
| 62 |
|
| 63 |
|
| 64 |
Installation |
| 65 |
------------ |
| 66 |
|
| 67 |
You can install "pytest-helpers-namespace" via `pip`_ from `PyPI`_:: |
| 68 |
|
| 69 |
$ pip install pytest-helpers-namespace |
| 70 |
|
| 71 |
|
| 72 |
Usage |
| 73 |
----- |
| 74 |
|
| 75 |
Consider the following ``conftest.py`` file: |
| 76 |
|
| 77 |
.. code-block:: python |
| 78 |
|
| 79 |
import pytest |
| 80 |
|
| 81 |
@pytest.helpers.register |
| 82 |
def foo(bar): |
| 83 |
''' |
| 84 |
this dumb helper function will just return what you pass to it |
| 85 |
''' |
| 86 |
return bar |
| 87 |
|
| 88 |
|
| 89 |
And now consider the following test case: |
| 90 |
|
| 91 |
.. code-block:: python |
| 92 |
|
| 93 |
def test_helper_namespace(): |
| 94 |
assert pytest.helpers.foo(True) is True |
| 95 |
|
| 96 |
|
| 97 |
Pretty simple right?! |
| 98 |
|
| 99 |
|
| 100 |
You can even nest namespaces. Consider the following ``conftest.py`` file: |
| 101 |
|
| 102 |
.. code-block:: python |
| 103 |
|
| 104 |
pytest_plugins = ['helpers_namespace'] |
| 105 |
|
| 106 |
import pytest |
| 107 |
|
| 108 |
@pytest.helpers.can.haz.register |
| 109 |
def foo(bar): |
| 110 |
''' |
| 111 |
this dumb helper function will just return what you pass to it |
| 112 |
''' |
| 113 |
return bar |
| 114 |
|
| 115 |
|
| 116 |
And now consider the following test case: |
| 117 |
|
| 118 |
.. code-block:: python |
| 119 |
|
| 120 |
def test_helper_namespace(): |
| 121 |
assert pytest.helpers.can.haz.foo(True) is True |
| 122 |
|
| 123 |
|
| 124 |
You can even pass a name to the register function and that will be the helper function name. |
| 125 |
|
| 126 |
|
| 127 |
Contributing |
| 128 |
------------ |
| 129 |
Contributions are very welcome. Tests can be run with `nox`_, please ensure |
| 130 |
the coverage at least stays the same before you submit a pull request. |
| 131 |
|
| 132 |
License |
| 133 |
------- |
| 134 |
|
| 135 |
Distributed under the terms of the `Apache Software License 2.0`_ license, |
| 136 |
"pytest-helpers-namespace" is free and open source software. |
| 137 |
|
| 138 |
|
| 139 |
Issues |
| 140 |
------ |
| 141 |
|
| 142 |
If you encounter any problems, please `file an issue`_ along with a detailed |
| 143 |
description. |
| 144 |
|
| 145 |
Changelog |
| 146 |
--------- |
| 147 |
|
| 148 |
v2021.3.24 |
| 149 |
~~~~~~~~~~ |
| 150 |
|
| 151 |
* Switched project to a ``src`` layout. |
| 152 |
* Switched project to a declarative setuptools approach |
| 153 |
* Added support to check if a helper has been registered |
| 154 |
* Pytest >= 6.1.1 is now required |
| 155 |
|
| 156 |
v2019.1.8 |
| 157 |
~~~~~~~~~ |
| 158 |
|
| 159 |
* Patch PyTest before any ``conftest.py`` file is processed. |
| 160 |
|
| 161 |
v2019.1.7 |
| 162 |
~~~~~~~~~ |
| 163 |
|
| 164 |
* Support PyTest >= 4.1 |
| 165 |
|
| 166 |
v2019.1.6.post1 |
| 167 |
~~~~~~~~~~~~~~~ |
| 168 |
|
| 169 |
* No changes were made besides locking to PyTest < 4.0 |
| 170 |
|
| 171 |
v2019.1.6 |
| 172 |
~~~~~~~~~ |
| 173 |
|
| 174 |
* No changes were made besides locking to PyTest < 4.1 |
| 175 |
|
| 176 |
v2017.11.11 |
| 177 |
~~~~~~~~~~~ |
| 178 |
|
| 179 |
* Allow passing a string to the register function which will be the helper name |
| 180 |
|
| 181 |
v2016.7.10 |
| 182 |
~~~~~~~~~~ |
| 183 |
|
| 184 |
* Allow a registered function to contibue to behave as a regular function. `#4`_. |
| 185 |
|
| 186 |
v2016.4.15 |
| 187 |
~~~~~~~~~~ |
| 188 |
|
| 189 |
* Hide the ``FuncWrapper`` traceback in pytest failures. `#3`_. Thanks Logan Glickfield(`@lsglick`_) |
| 190 |
|
| 191 |
v2016.4.5 |
| 192 |
~~~~~~~~~ |
| 193 |
|
| 194 |
* Use a wrapper class instead of adding an attribute to a function. |
| 195 |
|
| 196 |
v2016.4.3 |
| 197 |
~~~~~~~~~ |
| 198 |
|
| 199 |
* Provide proper errors when helper functions or namespaces are being |
| 200 |
overridden. `#1`_ |
| 201 |
|
| 202 |
v2016.3.2 |
| 203 |
~~~~~~~~~~ |
| 204 |
|
| 205 |
* First working release |
| 206 |
|
| 207 |
---- |
| 208 |
|
| 209 |
This `Pytest`_ plugin was generated with `Cookiecutter`_ along with |
| 210 |
`@hackebrot`_'s `Cookiecutter-pytest-plugin`_ template. |
| 211 |
|
| 212 |
.. _`Cookiecutter`: https://github.com/audreyr/cookiecutter |
| 213 |
.. _`@hackebrot`: https://github.com/hackebrot |
| 214 |
.. _`Apache Software License 2.0`: http://www.apache.org/licenses/LICENSE-2.0 |
| 215 |
.. _`cookiecutter-pytest-plugin`: https://github.com/pytest-dev/cookiecutter-pytest-plugin |
| 216 |
.. _`file an issue`: https://github.com/saltstack/pytest-helpers-namespace/issues |
| 217 |
.. _`pytest`: https://github.com/pytest-dev/pytest |
| 218 |
.. _`nox`: https://nox.thea.codes/en/stable/ |
| 219 |
.. _`pip`: https://pypi.python.org/pypi/pip/ |
| 220 |
.. _`PyPI`: https://pypi.python.org/pypi |
| 221 |
|
| 222 |
.. _`#1`: https://github.com/saltstack/pytest-helpers-namespace/issues/1 |
| 223 |
.. _`#3`: https://github.com/saltstack/pytest-helpers-namespace/pull/3 |
| 224 |
.. _`#4`: https://github.com/saltstack/pytest-helpers-namespace/issues/4 |
| 225 |
|
| 226 |
.. _`@lsglick`: https://github.com/lsglick |
| 227 |
|
| 228 |
Platform: unix |
| 229 |
Platform: linux |
| 230 |
Platform: osx |
| 231 |
Platform: cygwin |
| 232 |
Platform: win32 |
| 233 |
Classifier: Programming Language :: Python |
| 234 |
Classifier: Programming Language :: Cython |
| 235 |
Classifier: Programming Language :: Python :: 3 |
| 236 |
Classifier: Programming Language :: Python :: 3 :: Only |
| 237 |
Classifier: Programming Language :: Python :: 3.5 |
| 238 |
Classifier: Programming Language :: Python :: 3.6 |
| 239 |
Classifier: Programming Language :: Python :: 3.7 |
| 240 |
Classifier: Programming Language :: Python :: 3.8 |
| 241 |
Classifier: Programming Language :: Python :: 3.9 |
| 242 |
Classifier: Development Status :: 5 - Production/Stable |
| 243 |
Classifier: Intended Audience :: Developers |
| 244 |
Classifier: License :: OSI Approved :: Apache Software License |
| 245 |
Requires-Python: >=3.5 |
| 246 |
Provides-Extra: docs |
| 247 |
Provides-Extra: lint |
| 248 |
Provides-Extra: tests |