Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Replace deprecated implprefix from pluggy with HookimplMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
davehunt committed Aug 13, 2018
1 parent febea46 commit 287fe1b
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ Then, in your package implement one or more of the plugin :ref:`hooks` provided
by PyPOM. The following example will take a screenshot whenever a page or
region has finished loading::


from pypom import hookimpl

@hookimpl
def pypom_after_wait_for_page_to_load(page):
page.selenium.get_screenshot_as_file(page.__class__.__name__ + '.png')


@hookimpl
def pypom_after_wait_for_region_to_load(region):
region.root.screenshot(region.__class__.__name__ + '.png')

Expand Down
3 changes: 3 additions & 0 deletions src/pypom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .page import Page # noqa
from .region import Region # noqa

import pluggy
import selenium # noqa

# register selenium support
Expand All @@ -16,3 +17,5 @@
from .splinter_driver import register as registerSplinter

registerSplinter()

hookimpl = pluggy.HookimplMarker("pypom")
18 changes: 18 additions & 0 deletions src/pypom/newsfragments/90.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Replace use of ``implprefix`` with ``HookimplMarker`` due to deprecation.

Existing PyPOM plugins will need to be updated to import the `hookimpl` and use
it to decorate hook implementations rather than rely on the prefix of the
function names.

Before::

def pypom_after_wait_for_page_to_load(page):
pass

After::

from pypom import hookimpl

@hookimpl
def pypom_after_wait_for_page_to_load(page):
pass
2 changes: 1 addition & 1 deletion src/pypom/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, driver, timeout, pm=None):
self.timeout = timeout
self.pm = pm
if self.pm is None:
self.pm = PluginManager("pypom", implprefix="pypom_")
self.pm = PluginManager("pypom")
self.pm.add_hookspecs(hooks)
self.pm.load_setuptools_entrypoints("pypom.plugin")
self.pm.check_pending()
Expand Down

0 comments on commit 287fe1b

Please sign in to comment.