Message131838
If you add the following test to text_contextlib:
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -363,6 +363,8 @@ class TestContextDecorator(unittest.Test
state.append(x)
test('something')
self.assertEqual(state, [1, 'something', 999])
+ test('something else')
+ self.assertEqual(state, [1, 'something', 999, 1, 'something else', 999])
# This is needed to make the test actually run under regrtest.py!
You get the following error:
======================================================================
ERROR: test_contextmanager_as_decorator (test.test_contextlib.TestContextDecorator)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/antoine/cpython/32/Lib/contextlib.py", line 28, in __enter__
return next(self.gen)
StopIteration
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/antoine/cpython/32/Lib/test/test_contextlib.py", line 366, in test_contextmanager_as_decorator
test('something else')
File "/home/antoine/cpython/32/Lib/contextlib.py", line 15, in inner
with self:
File "/home/antoine/cpython/32/Lib/contextlib.py", line 30, in __enter__
raise RuntimeError("generator didn't yield")
RuntimeError: generator didn't yield
Clearly there is a problem in the API or its implementation, as in a function decorated with a context manager can only be invoked once! This isn't good... |
|
Date |
User |
Action |
Args |
2011-03-23 02:04:38 | pitrou | set | recipients:
+ pitrou, ncoghlan, michael.foord |
2011-03-23 02:04:38 | pitrou | set | messageid: <1300845878.3.0.475491224846.issue11647@psf.upfronthosting.co.za> |
2011-03-23 02:04:37 | pitrou | link | issue11647 messages |
2011-03-23 02:04:37 | pitrou | create | |
|