From bd9495486b7c45a1aadd5fa94a95110ac450a143 Mon Sep 17 00:00:00 2001 From: Niclas Olofsson Date: Sat, 26 Sep 2015 15:23:11 +0200 Subject: [PATCH] pytest 2.7 compatibility. --- pytest_stepwise/compat.py | 8 ++++++++ pytest_stepwise/plugin.py | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pytest_stepwise/compat.py b/pytest_stepwise/compat.py index 31f132c70..ce28f7474 100644 --- a/pytest_stepwise/compat.py +++ b/pytest_stepwise/compat.py @@ -1,4 +1,12 @@ +import pytest + try: from _pytest.cacheprovider import Cache except ImportError: from pytest_cache import Cache + + +if hasattr(pytest, 'hookimpl'): + tryfirst = pytest.hookimpl(tryfirst=True) +else: + tryfirst = pytest.mark.tryfirst diff --git a/pytest_stepwise/plugin.py b/pytest_stepwise/plugin.py index 89cd5125b..1f0137a46 100644 --- a/pytest_stepwise/plugin.py +++ b/pytest_stepwise/plugin.py @@ -1,5 +1,4 @@ -import pytest -from .compat import Cache +from .compat import Cache, tryfirst def pytest_addoption(parser): @@ -12,7 +11,7 @@ def pytest_addoption(parser): help='ignore the first failing test but stop on the next failing test') -@pytest.hookimpl(tryfirst=True) +@tryfirst def pytest_configure(config): config.cache = Cache(config) config.pluginmanager.register(StepwisePlugin(config), 'stepwiseplugin')