summaryrefslogtreecommitdiff
path: root/Lib/test/test_contextlib.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-06-28 17:09:11 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2015-06-28 17:09:11 +0300
commit9aad9f27407861d674570bf5c0bd957bbe13663b (patch)
tree90c1467cde02dbc8e1006123aa07b18cd5ca7495 /Lib/test/test_contextlib.py
parent2eff9e9441d76904792141b4b38b0eb649d9eb86 (diff)
parenteab770404437bd49ebf897b681221784b0035795 (diff)
downloadcpython-git-9aad9f27407861d674570bf5c0bd957bbe13663b.tar.gz
Issue #24336: The contextmanager decorator now works with functions with
keyword arguments called "func" and "self". Patch by Martin Panter.
Diffstat (limited to 'Lib/test/test_contextlib.py')
-rw-r--r--Lib/test/test_contextlib.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index adafc9fd4f..78741f5f2b 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -147,6 +147,14 @@ def woohoo():
baz = self._create_contextmanager_attribs()(None)
self.assertEqual(baz.__doc__, "Whee!")
+ def test_keywords(self):
+ # Ensure no keyword arguments are inhibited
+ @contextmanager
+ def woohoo(self, func, args, kwds):
+ yield (self, func, args, kwds)
+ with woohoo(self=11, func=22, args=33, kwds=44) as target:
+ self.assertEqual(target, (11, 22, 33, 44))
+
class ClosingTestCase(unittest.TestCase):