mirror of
https://github.com/jazzband/contextlib2.git
synced 2026-03-16 21:50:24 +00:00
Issue #5: ContextStack.register no longer pointlessly returns the wrapped function
This commit is contained in:
parent
7cab096ee8
commit
8bca9f8cd0
3 changed files with 7 additions and 5 deletions
2
NEWS.rst
2
NEWS.rst
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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__)
|
||||
|
|
|
|||
Loading…
Reference in a new issue