From 7b5d9b805f50842ab10c38a68e0f0beca11b17f5 Mon Sep 17 00:00:00 2001 From: Jeff Meadows Date: Thu, 10 Jan 2019 10:57:48 -0800 Subject: [PATCH] Fix #143 - fall back to old pytest marker API for older pytest version (#144) --- flaky/flaky_pytest_plugin.py | 12 +++++++++--- setup.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/flaky/flaky_pytest_plugin.py b/flaky/flaky_pytest_plugin.py index ab0715b..4b2eedd 100644 --- a/flaky/flaky_pytest_plugin.py +++ b/flaky/flaky_pytest_plugin.py @@ -228,9 +228,15 @@ def pytest_runtest_setup(self, item): :param item: The test item. """ - for marker in item.iter_markers(name='flaky'): - if not self._has_flaky_attributes(item): - self._make_test_flaky(item, *marker.args, **marker.kwargs) + if not self._has_flaky_attributes(item): + if hasattr(item, 'iter_markers'): + for marker in item.iter_markers(name='flaky'): + self._make_test_flaky(item, *marker.args, **marker.kwargs) + break + elif hasattr(item, 'get_marker'): + marker = item.get_marker('flaky') + if marker: + self._make_test_flaky(item, *marker.args, **marker.kwargs) def pytest_sessionfinish(self): """ diff --git a/setup.py b/setup.py index 32fd6a5..32fe5a1 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ def main(): base_dir = dirname(__file__) setup( name='flaky', - version='3.5.1', + version='3.5.2', description='Plugin for nose or pytest that automatically reruns flaky tests.', long_description=open(join(base_dir, 'README.rst')).read(), author='Box',