diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-06-28 17:06:07 +0300 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-06-28 17:06:07 +0300 |
commit | 6ea82ec7a7990220fd423ee7a777484dd24089b3 (patch) | |
tree | 2a592e5db3ebd7394e73f04f160bb3a9e4cea0e6 /Lib/test/test_contextlib.py | |
parent | dcfaff6331ae24a19a2c9db3b7c8ba71fb5e418f (diff) | |
download | cpython-6ea82ec7a7990220fd423ee7a777484dd24089b3.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.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py index 39cc776dbc..8f849ae560 100644 --- a/Lib/test/test_contextlib.py +++ b/Lib/test/test_contextlib.py @@ -111,6 +111,14 @@ class ContextManagerTestCase(unittest.TestCase): 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): |