<s> """<STR_LIT>""" <EOL> from __future__ import division , absolute_import <EOL> import sys <EOL> from twisted . trial . unittest import TestCase <EOL> from twisted . internet . defer import Deferred , returnValue , inlineCallbacks <EOL> class StopIterationReturnTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_returnWithValue ( self ) : <EOL> """<STR_LIT>""" <EOL> environ = { "<STR_LIT>" : inlineCallbacks } <EOL> exec ( """<STR_LIT>""" , environ ) <EOL> d1 = Deferred ( ) <EOL> d2 = environ [ "<STR_LIT:f>" ] ( d1 ) <EOL> d1 . callback ( None ) <EOL> self . assertEqual ( self . successResultOf ( d2 ) , <NUM_LIT> ) <EOL> if sys . version_info < ( <NUM_LIT:3> , <NUM_LIT:3> ) : <EOL> StopIterationReturnTests . skip = "<STR_LIT>" <EOL> class NonLocalExitTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def mistakenMethod ( self ) : <EOL> """<STR_LIT>""" <EOL> returnValue ( <NUM_LIT:1> ) <EOL> def assertMistakenMethodWarning ( self , resultList ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( resultList , [ <NUM_LIT:1> ] ) <EOL> warnings = self . flushWarnings ( offendingFunctions = [ self . mistakenMethod ] ) <EOL> self . assertEqual ( len ( warnings ) , <NUM_LIT:1> ) <EOL> self . assertEqual ( warnings [ <NUM_LIT:0> ] [ '<STR_LIT>' ] , DeprecationWarning ) <EOL> self . assertEqual ( <EOL> warnings [ <NUM_LIT:0> ] [ '<STR_LIT:message>' ] , <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> def test_returnValueNonLocalWarning ( self ) : <EOL> """<STR_LIT>""" <EOL> @ inlineCallbacks <EOL> def inline ( ) : <EOL> self . mistakenMethod ( ) <EOL> returnValue ( <NUM_LIT:2> ) <EOL> yield <NUM_LIT:0> <EOL> d = inline ( ) <EOL> results = [ ] <EOL> d . addCallback ( results . append ) <EOL> self . assertMistakenMethodWarning ( results ) <EOL> def test_returnValueNonLocalDeferred ( self ) : <EOL> """<STR_LIT>""" <EOL> cause = Deferred ( ) <EOL> @ inlineCallbacks <EOL> def inline ( ) : <EOL> yield cause <EOL> self . mistakenMethod ( ) <EOL> returnValue ( <NUM_LIT:2> ) <EOL> effect = inline ( ) <EOL> results = [ ] <EOL> effect . addCallback ( results . append ) <EOL> self . assertEqual ( results , [ ] ) <EOL> cause . callback ( <NUM_LIT:1> ) <EOL> self . assertMistakenMethodWarning ( results ) </s>
