<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import , division , print_function <EOL> from zope . interface . verify import verifyObject <EOL> from twisted . trial . unittest import SynchronousTestCase <EOL> from . . import AlreadyQuit , IWorker , createMemoryWorker <EOL> class MemoryWorkerTests ( SynchronousTestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_createWorkerAndPerform ( self ) : <EOL> """<STR_LIT>""" <EOL> worker , performer = createMemoryWorker ( ) <EOL> verifyObject ( IWorker , worker ) <EOL> done = [ ] <EOL> worker . do ( lambda : done . append ( <NUM_LIT:3> ) ) <EOL> worker . do ( lambda : done . append ( <NUM_LIT:4> ) ) <EOL> self . assertEqual ( done , [ ] ) <EOL> self . assertEqual ( performer ( ) , True ) <EOL> self . assertEqual ( done , [ <NUM_LIT:3> ] ) <EOL> self . assertEqual ( performer ( ) , True ) <EOL> self . assertEqual ( done , [ <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> def test_quitQuits ( self ) : <EOL> """<STR_LIT>""" <EOL> worker , performer = createMemoryWorker ( ) <EOL> done = [ ] <EOL> def moreWork ( ) : <EOL> done . append ( <NUM_LIT:7> ) <EOL> worker . do ( moreWork ) <EOL> worker . quit ( ) <EOL> self . assertRaises ( AlreadyQuit , worker . do , moreWork ) <EOL> self . assertRaises ( AlreadyQuit , worker . quit ) <EOL> performer ( ) <EOL> self . assertEqual ( done , [ <NUM_LIT:7> ] ) <EOL> self . assertEqual ( performer ( ) , False ) <EOL> def test_performWhenNothingToDoYet ( self ) : <EOL> """<STR_LIT>""" <EOL> worker , performer = createMemoryWorker ( ) <EOL> self . assertEqual ( performer ( ) , False ) </s>
