Index: Lib/test/test_with.py =================================================================== --- Lib/test/test_with.py (revision 5721) +++ Lib/test/test_with.py (working copy) @@ -237,6 +237,14 @@ pass self.assertAfterWithManagerInvariantsNoError(mock) + def testUnboundGeneratorReturn(self): + mock = mock_contextmanager_generator() + def shouldReturnWithExitCalled( inner_mock ): + with inner_mock: + return + shouldReturnWithExitCalled(mock) + self.assertAfterWithManagerInvariantsNoError(mock) + def testInlineGeneratorBoundSyntax(self): with mock_contextmanager_generator() as foo: self.assertInWithGeneratorInvariants(foo)