From: Benjamin Peterson Date: Fri, 29 May 2009 21:48:19 +0000 (+0000) Subject: add with statements X-Git-Tag: v2.7a1~1072 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=465089271fe32e8e5c573abeca13489553d27982;p=python add with statements --- diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index f8cef6ac94..17f9f4c51c 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -920,6 +920,26 @@ hello world self.assertEqual([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) self.assertEqual(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + def test_with_statement(self): + class manager(object): + def __enter__(self): + return (1, 2) + def __exit__(self, *args): + pass + + with manager(): + pass + with manager() as x: + pass + with manager() as (x, y): + pass + with manager(), manager(): + pass + with manager() as x, manager() as y: + pass + with manager() as x, manager(): + pass + def testIfElseExpr(self): # Test ifelse expressions in various cases def _checkeval(msg, ret):