From 81749d8701de1d3dfed5fdbb5913e85f84159ff6 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:07:44 +0100 Subject: [PATCH 01/13] Typo fixes --- setup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index c92df36..8947386 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ from distutils.core import setup + setup( name='pyretry', version="0.9", - description='Separate your retry logic from your buxiness lgic', + description='Separate your retry logic from your business logic', author='Bob Renwick', author_email='bob.renwick@gmail.com', url='https://github.com/bobbyrenwick/pyretry', @@ -16,4 +17,4 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', ), -) \ No newline at end of file +) From f685da48f2e3bab40ccaf71965550236c697f230 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:07:51 +0100 Subject: [PATCH 02/13] Add python 3 tag --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 8947386..0e8f771 100644 --- a/setup.py +++ b/setup.py @@ -16,5 +16,6 @@ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', ), ) From 451acf349309cd6bdc8e1d6fca4fcd1e02f36a11 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:21:05 +0100 Subject: [PATCH 03/13] Move to setuptools --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0e8f771..68addad 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -from distutils.core import setup +from setuptools import setup setup( From d8eb285aa526de6a2fc46b76693737820030f5c5 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:22:58 +0100 Subject: [PATCH 04/13] pep8 fixes --- pyretry/pyretry.py | 4 +++- pyretry/tests.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pyretry/pyretry.py b/pyretry/pyretry.py index 3d4faa9..287a8b6 100644 --- a/pyretry/pyretry.py +++ b/pyretry/pyretry.py @@ -1,6 +1,8 @@ -from functools import wraps import time +from functools import wraps + + def retry(exceptions_to_catch, num_retries=5, timeout=0, hook=None): def decorator(func): @wraps(func) diff --git a/pyretry/tests.py b/pyretry/tests.py index de73e1b..7c4a9d3 100644 --- a/pyretry/tests.py +++ b/pyretry/tests.py @@ -1,17 +1,22 @@ import unittest + import mock -from pyretry import retry +from .pyretry import retry + class RetryableError(Exception): pass + class DifferentRetryableError(Exception): pass + class UnretryableError(Exception): pass + class TestPyretry(unittest.TestCase): def setUp(self): From 1700a0eed2f2261b61947e985e339f8426ff47fe Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:23:10 +0100 Subject: [PATCH 05/13] Replace `xrange` with `range` - normal use cases of the library should keep `num_retries` to a sensible number, so `xrange` was not a strictly necessary optimisation - `xrange` does not exist in python 3 (or rather, its implementation is now in `range`) --- pyretry/pyretry.py | 2 +- pyretry/tests.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyretry/pyretry.py b/pyretry/pyretry.py index 287a8b6..66504f3 100644 --- a/pyretry/pyretry.py +++ b/pyretry/pyretry.py @@ -9,7 +9,7 @@ def decorator(func): def wrapper(*args, **kwargs): timeout_is_func = hasattr(timeout, '__call__') - for i in xrange(num_retries + 1): + for i in range(num_retries + 1): attempt_number = i + 1 try: diff --git a/pyretry/tests.py b/pyretry/tests.py index 7c4a9d3..51b4a95 100644 --- a/pyretry/tests.py +++ b/pyretry/tests.py @@ -111,7 +111,7 @@ def always_fails(): self.assertRaises(RetryableError, always_fails) self.assertEqual(self.counter, 6) - expected = [mock.call(i + 1) for i in xrange(5)] + expected = [mock.call(i + 1) for i in range(5)] self.assertEqual(timeout_calc.call_args_list, expected) def test_hook_is_called(self): From 8b19d6d0dc23c4014bac44e3379e74760de3fc71 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:25:59 +0100 Subject: [PATCH 06/13] Ignore unusable import issue, it's intended --- pyretry/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyretry/__init__.py b/pyretry/__init__.py index ec263d0..603fcb8 100644 --- a/pyretry/__init__.py +++ b/pyretry/__init__.py @@ -1 +1 @@ -from pyretry import retry \ No newline at end of file +from .pyretry import retry # noqa From 08347214e93d9cfe9ad53a528aea3428afeb49a0 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:35:07 +0100 Subject: [PATCH 07/13] Add missing `tests_require` for `mock` --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 68addad..a3d7b02 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,9 @@ author_email='bob.renwick@gmail.com', url='https://github.com/bobbyrenwick/pyretry', packages=['pyretry'], + tests_require=[ + 'mock>=1.0,<1.1', + ], classifiers=( 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', From 1a1a58c8977ed3787454a218af041da6a13af4a9 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:41:43 +0100 Subject: [PATCH 08/13] Get Travis to build the project in python 3 too A bunch of them, at that --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9764383..dcb1edd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,12 @@ language: python python: - "2.7" + - "3.2" + - "3.3" + - "3.4" + - "3.5" install: - "pip install -r requirements.pip" - "pip install coveralls" script: nosetests --with-coverage --cover-package=pyretry -after_success: coveralls \ No newline at end of file +after_success: coveralls From ffb1634e89a4ca82d62f35b8befb05b29fe5b401 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:45:09 +0100 Subject: [PATCH 09/13] Revert "Add missing `tests_require` for `mock`" This reverts commit 08347214e93d9cfe9ad53a528aea3428afeb49a0. I hadn't noticed the requirements.pip file! --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index a3d7b02..68addad 100644 --- a/setup.py +++ b/setup.py @@ -9,9 +9,6 @@ author_email='bob.renwick@gmail.com', url='https://github.com/bobbyrenwick/pyretry', packages=['pyretry'], - tests_require=[ - 'mock>=1.0,<1.1', - ], classifiers=( 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', From 53fe81ddea96652760fd65263a0ebb3d91a54e6d Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:55:26 +0100 Subject: [PATCH 10/13] Replace nose with nose2 for python3 compatibility --- requirements.pip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.pip b/requirements.pip index aaff70f..4942377 100644 --- a/requirements.pip +++ b/requirements.pip @@ -1,3 +1,3 @@ mock==1.0.1 -nose==1.3.0 +nose2[coverage-plugin]==0.6.5 wsgiref==0.1.2 From 430ab892081369a2a4e67c68cb44537b342399b8 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:55:42 +0100 Subject: [PATCH 11/13] Remove wsgiref dependency As far as I could tell it's not used anywhere and also can't be installed under python3. --- requirements.pip | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.pip b/requirements.pip index 4942377..5a4a76b 100644 --- a/requirements.pip +++ b/requirements.pip @@ -1,3 +1,2 @@ mock==1.0.1 nose2[coverage-plugin]==0.6.5 -wsgiref==0.1.2 From 111d41e682cf954830b8dd2fa9e7e8879551a333 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:56:25 +0100 Subject: [PATCH 12/13] Change testrunner command to nose2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dcb1edd..1a2f0e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ python: install: - "pip install -r requirements.pip" - "pip install coveralls" -script: nosetests --with-coverage --cover-package=pyretry +script: nose2 --with-coverage --cover-package=pyretry after_success: coveralls From 54b079c73c3d6b139c29db47a24c34fce8a71b92 Mon Sep 17 00:00:00 2001 From: Panos Katseas Date: Sun, 21 Aug 2016 22:58:40 +0100 Subject: [PATCH 13/13] Update wrong flag for coverage path --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a2f0e0..2f6eb04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,5 +8,5 @@ python: install: - "pip install -r requirements.pip" - "pip install coveralls" -script: nose2 --with-coverage --cover-package=pyretry +script: nose2 --with-coverage --coverage=pyretry after_success: coveralls