diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-06-28 14:08:35 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-06-28 14:08:35 (GMT) |
commit | eab770404437bd49ebf897b681221784b0035795 (patch) | |
tree | 291450eb49145a982a5d30b60f31070d5eb56fdf /Lib/test/test_contextlib.py | |
parent | 4801383c2953d3a45beafa1e945d60412460b9c3 (diff) | |
parent | 101ff3541cbe5bd9549722dc53c28d6c21b9389c (diff) | |
download | cpython-eab770404437bd49ebf897b681221784b0035795.zip cpython-eab770404437bd49ebf897b681221784b0035795.tar.gz cpython-eab770404437bd49ebf897b681221784b0035795.tar.bz2 |
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.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index adafc9f..78741f5 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): |