Skip to content

Commit

Permalink
Decorated functions were not returning.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Feb 1, 2012
1 parent 39bda4f commit f10c56b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
*.egg-info
*.DS_Store
*tests/s3/
*build
*dist
2 changes: 1 addition & 1 deletion pytoad/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def pytoad_decorator(monitored_exceptions=[], PytoadConnectionClass=Connection):
def wrap(f):
def wrapped_f(*args, **kwargs):
try:
f(*args, **kwargs)
return f(*args, **kwargs)
except Exception, e:
if e.__class__ in monitored_exceptions or not monitored_exceptions:
connection = PytoadConnectionClass()
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import setup, find_packages

setup(name="Pytoad",
version="1.0.2",
version="1.0.3",
description="Pytoad is a lightweight Hoptoad notifier for Python.",
author="Benjamin Coe",
author_email="ben@attachments.me",
Expand Down
10 changes: 10 additions & 0 deletions tests/test_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ def foobar():
foobar()

self.assertTrue( MockPytoadConnection.exceptions )

def test_decorated_functions_return(self):

MockPytoadConnection.exceptions = []

@pytoad_decorator(PytoadConnectionClass=MockPytoadConnection)
def foobar():
return 'foobar'

self.assertEqual( foobar(), 'foobar' )

def test_decorator_catches_only_monitored_exceptions_if_provided(self):

Expand Down

0 comments on commit f10c56b

Please sign in to comment.