Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: pytest-dev/pluggy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.8.1
Choose a base ref
...
head repository: pytest-dev/pluggy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0.9.0
Choose a head ref
  • 10 commits
  • 8 files changed
  • 4 contributors

Commits on Jan 3, 2019

  1. Add html local toc sidebar to docs

    The new version of alabaster requires explicitly setting which sidebars
    should be displayed. Copy `tox` for now.
    
    Fixes #171
    Tyler Goodlet committed Jan 3, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    a2939c0 View commit details
  2. Merge pull request #185 from tgoodlet/sidebar_again

    Add html local toc sidebar to docs
    goodboy authored Jan 3, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    d0471e8 View commit details

Commits on Jan 9, 2019

  1. Merge pull request #184 from nicoddemus/release-0.8.1

    Release 0.8.1
    nicoddemus authored Jan 9, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    cfba99d View commit details

Commits on Jan 28, 2019

  1. Add testing for pypy3

    Fix #187
    nicoddemus committed Jan 28, 2019

    Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    666bb4b View commit details

Commits on Feb 8, 2019

  1. Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    1d6b381 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    antfu Anthony Fu
    Copy the full SHA
    893b546 View commit details
  3. Copy the full SHA
    0e0f054 View commit details

Commits on Feb 16, 2019

  1. Merge pull request #188 from nicoddemus/pypy3

    Add testing for pypy3
    goodboy authored Feb 16, 2019
    Copy the full SHA
    9a12ad4 View commit details

Commits on Feb 21, 2019

  1. Merge pull request #189 from nicoddemus/early-load-4718

    Add name parameter to PluginManager.load_setuptools_entrypoints
    nicoddemus authored Feb 21, 2019
    Copy the full SHA
    3c384dd View commit details
  2. Preparing release 0.9.0

    nicoddemus committed Feb 21, 2019
    Copy the full SHA
    b6a6c72 View commit details
Showing with 60 additions and 16 deletions.
  1. +3 −0 .gitignore
  2. +2 −0 .travis.yml
  3. +20 −0 CHANGELOG.rst
  4. +9 −4 docs/conf.py
  5. +7 −2 pluggy/hooks.py
  6. +12 −5 pluggy/manager.py
  7. +6 −4 testing/test_pluginmanager.py
  8. +1 −1 tox.ini
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -59,3 +59,6 @@ target/

# generated by setuptools_scm
pluggy/_version.py

# generated by pip
pip-wheel-metadata/
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@ jobs:
env: TOXENV=py36-pytestrelease
- python: 'pypy'
env: TOXENV=pypy-pytestrelease
- python: 'pypy3.5'
env: TOXENV=pypy3-pytestrelease
- python: 'nightly'
env: TOXENV=py37-pytestrelease
- python: '2.7'
20 changes: 20 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
pluggy 0.9.0 (2019-02-21)
=========================

Features
--------

- `#189 <https://github.com/pytest-dev/pluggy/issues/189>`_: ``PluginManager.load_setuptools_entrypoints`` now accepts a ``name`` parameter that when given will
load only entry points with that name.

``PluginManager.load_setuptools_entrypoints`` also now returns the number of plugins loaded by the
call, as opposed to the number of all plugins loaded by all calls to this method.



Bug Fixes
---------

- `#187 <https://github.com/pytest-dev/pluggy/issues/187>`_: Fix internal ``varnames`` function for PyPy3.


pluggy 0.8.1 (2018-11-09)
=========================

13 changes: 9 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -33,19 +33,24 @@
language = None

pygments_style = "sphinx"
html_logo = "_static/img/plug.png"
# html_logo = "_static/img/plug.png"
html_theme = "alabaster"
html_theme_options = {
# 'logo': 'img/plug.png',
# 'logo_name': 'true',
"description": "The `pytest` plugin system",
"logo": "img/plug.png",
"description": "The pytest plugin system",
"github_user": "pytest-dev",
"github_repo": "pluggy",
"github_button": "true",
"github_banner": "true",
"github_type": "star",
"travis_button": "true",
"badge_branch": "master",
"page_width": "1080px",
"fixed_sidebar": "false",
}
html_sidebars = {
"**": ["about.html", "localtoc.html", "relations.html", "searchbox.html"]
}
html_static_path = ["_static"]

# One entry per manual page. List of tuples
9 changes: 7 additions & 2 deletions pluggy/hooks.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
Internal hook annotation, representation and calling machinery.
"""
import inspect
import sys
import warnings
from .callers import _legacymulticall, _multicall

@@ -135,6 +136,9 @@ def _getargspec(func):
return inspect.getargspec(func)


_PYPY3 = hasattr(sys, "pypy_version_info") and sys.version_info.major == 3


def varnames(func):
"""Return tuple of positional and keywrord argument names for a function,
method, class or callable.
@@ -172,13 +176,14 @@ def varnames(func):
defaults = ()

# strip any implicit instance arg
# pypy3 uses "obj" instead of "self" for default dunder methods
implicit_names = ("self",) if not _PYPY3 else ("self", "obj")
if args:
if inspect.ismethod(func) or (
"." in getattr(func, "__qualname__", ()) and args[0] == "self"
"." in getattr(func, "__qualname__", ()) and args[0] in implicit_names
):
args = args[1:]

assert "self" not in args # best naming practises check?
try:
cache["_varnames"] = args, defaults
except TypeError:
17 changes: 12 additions & 5 deletions pluggy/manager.py
Original file line number Diff line number Diff line change
@@ -251,16 +251,22 @@ def check_pending(self):
% (name, hookimpl.plugin),
)

def load_setuptools_entrypoints(self, entrypoint_name):
""" Load modules from querying the specified setuptools entrypoint name.
Return the number of loaded plugins. """
def load_setuptools_entrypoints(self, group, name=None):
""" Load modules from querying the specified setuptools ``group``.
:param str group: entry point group to load plugins
:param str name: if given, loads only plugins with the given ``name``.
:rtype: int
:return: return the number of loaded plugins by this call.
"""
from pkg_resources import (
iter_entry_points,
DistributionNotFound,
VersionConflict,
)

for ep in iter_entry_points(entrypoint_name):
count = 0
for ep in iter_entry_points(group, name=name):
# is the plugin registered or blocked?
if self.get_plugin(ep.name) or self.is_blocked(ep.name):
continue
@@ -275,7 +281,8 @@ def load_setuptools_entrypoints(self, entrypoint_name):
)
self.register(plugin, name=ep.name)
self._plugin_distinfo.append((plugin, ep.dist))
return len(self._plugin_distinfo)
count += 1
return count

def list_plugin_distinfo(self):
""" return list of distinfo/plugin tuples for all setuptools registered
10 changes: 6 additions & 4 deletions testing/test_pluginmanager.py
Original file line number Diff line number Diff line change
@@ -449,8 +449,8 @@ def example_hook():
def test_load_setuptools_instantiation(monkeypatch, pm):
pkg_resources = pytest.importorskip("pkg_resources")

def my_iter(name):
assert name == "hello"
def my_iter(group, name=None):
assert group == "hello"

class EntryPoint(object):
name = "myname"
@@ -470,14 +470,16 @@ class PseudoPlugin(object):
plugin = pm.get_plugin("myname")
assert plugin.x == 42
assert pm.list_plugin_distinfo() == [(plugin, None)]
num = pm.load_setuptools_entrypoints("hello")
assert num == 0 # no plugin loaded by this call


def test_load_setuptools_version_conflict(monkeypatch, pm):
"""Check that we properly handle a VersionConflict problem when loading entry points"""
pkg_resources = pytest.importorskip("pkg_resources")

def my_iter(name):
assert name == "hello"
def my_iter(group, name=None):
assert group == "hello"

class EntryPoint(object):
name = "myname"
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist=linting,docs,py{27,34,35,36,py}-pytestrelease,py{27,36}-pytest{master,features}
envlist=linting,docs,py{27,34,35,36,py,py3}-pytestrelease,py{27,36}-pytest{master,features}

[testenv]
commands=pytest {posargs:testing/}