Skip to content

Commit

Permalink
Merge pull request #1 from pkatseas/python3
Browse files Browse the repository at this point in the history
Python3
  • Loading branch information
Bob Renwick authored Aug 22, 2016
2 parents ef65746 + 54b079c commit c7f8672
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 12 deletions.
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
script: nose2 --with-coverage --coverage=pyretry
after_success: coveralls
2 changes: 1 addition & 1 deletion pyretry/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from pyretry import retry
from .pyretry import retry # noqa
6 changes: 4 additions & 2 deletions pyretry/pyretry.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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)
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:
Expand Down
9 changes: 7 additions & 2 deletions pyretry/tests.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -106,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):
Expand Down
3 changes: 1 addition & 2 deletions requirements.pip
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
mock==1.0.1
nose==1.3.0
wsgiref==0.1.2
nose2[coverage-plugin]==0.6.5
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from distutils.core import setup
from setuptools 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',
Expand All @@ -15,5 +16,6 @@
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
),
)
)

0 comments on commit c7f8672

Please sign in to comment.