From 30a004ac7fcd4db3f8abe6e825bb64d6ec67c179 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sat, 11 Nov 2017 09:57:22 -0700 Subject: Import pytest-helpers-namespace_2017.11.11.orig.tar.gz --- PKG-INFO | 14 +++++++++++--- README.rst | 10 +++++++++- pytest_helpers_namespace.egg-info/PKG-INFO | 14 +++++++++++--- pytest_helpers_namespace/plugin.py | 18 ++++++++++++------ pytest_helpers_namespace/version.py | 4 ++-- setup.py | 2 +- 6 files changed, 46 insertions(+), 16 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index 0854329..a5a52bb 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-helpers-namespace -Version: 2016.7.10 +Version: 2017.11.11 Summary: PyTest Helpers Namespace Home-page: https://github.com/saltstack/pytest-helpers-namespace Author: Pedro Algarvio @@ -13,7 +13,7 @@ Description: Pytest Helpers Namespace :target: https://travis-ci.org/saltstack/pytest-helpers-namespace :alt: See Build Status on Travis CI - .. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master + .. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master&svg=true :target: https://ci.appveyor.com/project/saltstack-public/pytest-helpers-namespace/branch/master :alt: See Build Status on AppVeyor @@ -124,6 +124,9 @@ Description: Pytest Helpers 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 @@ -145,6 +148,11 @@ Description: Pytest Helpers Namespace Changelog --------- + v2017.11.11 + ~~~~~~~~~~~ + + * Allow passing a string to the register function which will be the helper name + v2016.7.10 ~~~~~~~~~~ @@ -193,7 +201,7 @@ Description: Pytest Helpers Namespace .. _`@lsglick`: https://github.com/lsglick Platform: UNKNOWN -Classifier: Development Status :: 4 - Beta +Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing diff --git a/README.rst b/README.rst index 3b4ef7c..6b524c9 100644 --- a/README.rst +++ b/README.rst @@ -5,7 +5,7 @@ Pytest Helpers Namespace :target: https://travis-ci.org/saltstack/pytest-helpers-namespace :alt: See Build Status on Travis CI -.. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master +.. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master&svg=true :target: https://ci.appveyor.com/project/saltstack-public/pytest-helpers-namespace/branch/master :alt: See Build Status on AppVeyor @@ -116,6 +116,9 @@ And now consider the following test case: 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 @@ -137,6 +140,11 @@ description. Changelog --------- +v2017.11.11 +~~~~~~~~~~~ + +* Allow passing a string to the register function which will be the helper name + v2016.7.10 ~~~~~~~~~~ diff --git a/pytest_helpers_namespace.egg-info/PKG-INFO b/pytest_helpers_namespace.egg-info/PKG-INFO index 0854329..a5a52bb 100644 --- a/pytest_helpers_namespace.egg-info/PKG-INFO +++ b/pytest_helpers_namespace.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: pytest-helpers-namespace -Version: 2016.7.10 +Version: 2017.11.11 Summary: PyTest Helpers Namespace Home-page: https://github.com/saltstack/pytest-helpers-namespace Author: Pedro Algarvio @@ -13,7 +13,7 @@ Description: Pytest Helpers Namespace :target: https://travis-ci.org/saltstack/pytest-helpers-namespace :alt: See Build Status on Travis CI - .. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master + .. image:: https://ci.appveyor.com/api/projects/status/github/saltstack/pytest-helpers-namespace?branch=master&svg=true :target: https://ci.appveyor.com/project/saltstack-public/pytest-helpers-namespace/branch/master :alt: See Build Status on AppVeyor @@ -124,6 +124,9 @@ Description: Pytest Helpers 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 @@ -145,6 +148,11 @@ Description: Pytest Helpers Namespace Changelog --------- + v2017.11.11 + ~~~~~~~~~~~ + + * Allow passing a string to the register function which will be the helper name + v2016.7.10 ~~~~~~~~~~ @@ -193,7 +201,7 @@ Description: Pytest Helpers Namespace .. _`@lsglick`: https://github.com/lsglick Platform: UNKNOWN -Classifier: Development Status :: 4 - Beta +Classifier: Development Status :: 5 - Production/Stable Classifier: Framework :: Pytest Classifier: Intended Audience :: Developers Classifier: Topic :: Software Development :: Testing diff --git a/pytest_helpers_namespace/plugin.py b/pytest_helpers_namespace/plugin.py index 729036b..95ab3e5 100644 --- a/pytest_helpers_namespace/plugin.py +++ b/pytest_helpers_namespace/plugin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ''' :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` - :copyright: © 2016 by the SaltStack Team, see AUTHORS for more details. + :copyright: © 2016-2017 by the SaltStack Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. @@ -12,7 +12,8 @@ ''' # Import python libs -from functools import wraps +from functools import partial, wraps + class FuncWrapper(object): @@ -53,17 +54,22 @@ class HelpersRegistry(object): def __init__(self): self._registry = {} - def register(self, func): + def register(self, func, name=None): ''' Register's a new function as a helper ''' - if func.__name__ in self._registry: + if isinstance(func, str): + return partial(self.register, name=func) + + if name is None: + name = func.__name__ + if name in self._registry: raise RuntimeError( 'A helper function is already registered under the name: {0}'.format( - func.__name__ + name ) ) - self._registry[func.__name__] = wraps(func)(FuncWrapper(func)) + self._registry[name] = wraps(func)(FuncWrapper(func)) return func def __getattribute__(self, name): diff --git a/pytest_helpers_namespace/version.py b/pytest_helpers_namespace/version.py index 6e9d74b..12bc370 100644 --- a/pytest_helpers_namespace/version.py +++ b/pytest_helpers_namespace/version.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- ''' :codeauthor: :email:`Pedro Algarvio (pedro@algarvio.me)` - :copyright: © 2016 by the SaltStack Team, see AUTHORS for more details. + :copyright: © 2016-2017 by the SaltStack Team, see AUTHORS for more details. :license: Apache 2.0, see LICENSE for more details. @@ -16,5 +16,5 @@ from __future__ import absolute_import -__version_info__ = (2016, 7, 10) +__version_info__ = (2017, 11, 11) __version__ = '{0}.{1}.{2}'.format(*__version_info__) diff --git a/setup.py b/setup.py index 8279ffd..84a02c1 100644 --- a/setup.py +++ b/setup.py @@ -64,7 +64,7 @@ setup( packages=find_packages(), install_requires=['pytest>=2.9.1'], classifiers=[ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Framework :: Pytest', 'Intended Audience :: Developers', 'Topic :: Software Development :: Testing', -- cgit v1.2.3