Issue #5: ContextStack.register no longer pointlessly returns the wrapped function

This commit is contained in:
Nick Coghlan 2012-01-03 23:58:00 +10:00
parent 7cab096ee8
commit 8bca9f8cd0
3 changed files with 7 additions and 5 deletions

View file

@ -5,6 +5,8 @@ Release History
0.3 (2012-01-XX)
~~~~~~~~~~~~~~~~
* Issue #5: ContextStack.register no longer pointlessly returns the wrapped
function
* Issue #2: Add examples and recipes section to docs
* Issue #3: ContextStack.register_exit() now accepts objects with __exit__
attributes in addition to accepting exit callbacks directly

View file

@ -187,7 +187,7 @@ class ContextStack(object):
@wraps(callback)
def _wrapper(exc_type, exc, tb):
callback(*args, **kwds)
return self.register_exit(_wrapper)
self.register_exit(_wrapper)
def enter_context(self, cm):
"""Enters the supplied context manager

View file

@ -322,13 +322,13 @@ class TestContextStack(unittest.TestCase):
with ContextStack() as stack:
for args, kwds in reversed(expected):
if args and kwds:
stack.register(_exit, *args, **kwds)
self.assertIsNone(stack.register(_exit, *args, **kwds))
elif args:
stack.register(_exit, *args)
self.assertIsNone(stack.register(_exit, *args))
elif kwds:
stack.register(_exit, **kwds)
self.assertIsNone(stack.register(_exit, **kwds))
else:
stack.register(_exit)
self.assertIsNone(stack.register(_exit))
for wrapper in stack._callbacks:
self.assertEqual(wrapper.__name__, _exit.__name__)
self.assertEqual(wrapper.__doc__, _exit.__doc__)