<s> """<STR_LIT>""" <EOL> from twisted . trial import unittest <EOL> from twisted . python import filepath <EOL> from imaginary import iimaginary , objects , events <EOL> from imaginary . action import Action , TargetAction , Help <EOL> from imaginary . test import commandutils <EOL> from imaginary . test . commandutils import E <EOL> PTR = "<STR_LIT>" <EOL> STOREID = "<STR_LIT>" <EOL> class TransactionalEventBroadcasterTestCase ( unittest . TestCase ) : <EOL> def testAddEvent ( self ) : <EOL> L = [ ] <EOL> teb = events . TransactionalEventBroadcaster ( ) <EOL> teb . addEvent ( lambda : L . append ( '<STR_LIT>' ) ) <EOL> teb . addRevertEvent ( lambda : L . append ( '<STR_LIT>' ) ) <EOL> teb . broadcastEvents ( ) <EOL> self . assertEquals ( L , [ '<STR_LIT>' ] ) <EOL> def testAddRevertEvent ( self ) : <EOL> L = [ ] <EOL> teb = events . TransactionalEventBroadcaster ( ) <EOL> teb . addEvent ( lambda : L . append ( '<STR_LIT>' ) ) <EOL> teb . addRevertEvent ( lambda : L . append ( '<STR_LIT>' ) ) <EOL> teb . broadcastRevertEvents ( ) <EOL> self . assertEquals ( L , [ '<STR_LIT>' ] ) <EOL> def testBadEvents ( self ) : <EOL> teb = events . TransactionalEventBroadcaster ( ) <EOL> self . assertRaises ( ValueError , teb . addEvent , None ) <EOL> self . assertRaises ( ValueError , teb . addRevertEvent , None ) <EOL> class TargetActionTests ( commandutils . CommandTestCaseMixin , unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_resolveTarget ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> TargetAction ( ) . resolve ( self . player , "<STR_LIT:target>" , u"<STR_LIT>" ) , <EOL> [ self . observer ] ) <EOL> def test_resolveTargetCaseInsensitively ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> TargetAction ( ) . resolve ( self . player , "<STR_LIT:target>" , u"<STR_LIT>" ) , <EOL> [ self . observer ] ) <EOL> class Actions ( commandutils . CommandTestCaseMixin , unittest . TestCase ) : <EOL> def testBadCommand ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> def testInventory ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> playerContainer = iimaginary . IContainer ( self . player ) <EOL> playerContainer . add ( objects . Thing ( store = self . store , name = u"<STR_LIT>" ) ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> playerContainer . add ( objects . Thing ( store = self . store , name = u"<STR_LIT>" ) ) <EOL> playerContainer . add ( objects . Thing ( store = self . store , name = u"<STR_LIT>" ) ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> def test_actions ( self ) : <EOL> """<STR_LIT>""" <EOL> cmds = dict . fromkeys ( [ <EOL> getattr ( cls , '<STR_LIT>' , cls . __name__ . lower ( ) ) <EOL> for cls <EOL> in Action . actions ] ) . keys ( ) <EOL> cmds . sort ( ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ '<STR_LIT:U+0020>' . join ( cmds ) ] ) <EOL> def test_commands ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> def testGet ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . player . location , self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . location . location , None ) <EOL> o = objects . Thing ( store = self . store , name = u"<STR_LIT:foo>" ) <EOL> iimaginary . IContainer ( self . location ) . add ( o ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( o . location , self . player ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . observer . location , self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> c = objects . Thing ( store = self . store , name = u"<STR_LIT:bar>" ) <EOL> cContainer = objects . Container . createFor ( c , capacity = <NUM_LIT:1> ) <EOL> iimaginary . IContainer ( self . location ) . add ( c ) <EOL> o = objects . Thing ( store = self . store , name = u"<STR_LIT>" ) <EOL> cContainer . add ( o ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( o . location , self . player ) <EOL> o . moveTo ( c ) <EOL> cContainer . closed = True <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ ] ) <EOL> self . assertEquals ( o . location , c ) <EOL> self . assertEquals ( list ( cContainer . getContents ( ) ) , [ o ] ) <EOL> def testDrop ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> o = objects . Thing ( store = self . store , name = u"<STR_LIT:bar>" ) <EOL> iimaginary . IContainer ( self . player ) . add ( o ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( o . location , self . location ) <EOL> def testSay ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> def testEmote ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> def testDescribe ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . player . description , <EOL> "<STR_LIT>" ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . location . description , <EOL> "<STR_LIT>" ) <EOL> def testName ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . player . name , <EOL> "<STR_LIT>" ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( self . location . name , <EOL> "<STR_LIT>" ) <EOL> def testRestore ( self ) : <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> actor = iimaginary . IActor ( self . player ) <EOL> actor . hitpoints . decrease ( <NUM_LIT> ) <EOL> actor . stamina . decrease ( <NUM_LIT> ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( actor . hitpoints . current , <EOL> actor . hitpoints . max ) <EOL> self . assertEquals ( actor . stamina . current , <EOL> actor . stamina . max ) <EOL> oactor = iimaginary . IActor ( self . observer ) <EOL> oactor . hitpoints . decrease ( <NUM_LIT> ) <EOL> oactor . stamina . decrease ( <NUM_LIT> ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( oactor . hitpoints . current , <EOL> oactor . hitpoints . max ) <EOL> self . assertEquals ( oactor . stamina . current , <EOL> oactor . stamina . max ) <EOL> def testScore ( self ) : <EOL> x , y = self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> self . assertEquals ( x [ <NUM_LIT:0> ] . groups ( ) , ( ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:1> ] . groups ( ) , ( ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:2> ] . groups ( ) , ( '<STR_LIT:0>' , '<STR_LIT:0>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:3> ] . groups ( ) , ( '<STR_LIT:100>' , '<STR_LIT:100>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:4> ] . groups ( ) , ( '<STR_LIT:100>' , '<STR_LIT:100>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:5> ] . groups ( ) , ( ) ) <EOL> actor = iimaginary . IActor ( self . player ) <EOL> actor . level = <NUM_LIT:3> <EOL> actor . experience = <NUM_LIT> <EOL> actor . hitpoints . current = <NUM_LIT:32> <EOL> actor . hitpoints . max = <NUM_LIT> <EOL> actor . stamina . current = <NUM_LIT:12> <EOL> actor . stamina . max = <NUM_LIT> <EOL> x , y = self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] ) <EOL> self . assertEquals ( x [ <NUM_LIT:0> ] . groups ( ) , ( ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:1> ] . groups ( ) , ( ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:2> ] . groups ( ) , ( '<STR_LIT:3>' , '<STR_LIT>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:3> ] . groups ( ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:4> ] . groups ( ) , ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . assertEquals ( x [ <NUM_LIT:5> ] . groups ( ) , ( ) ) <EOL> def test_dig ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> room = iimaginary . IContainer ( self . location ) . getExitNamed ( u'<STR_LIT>' ) . toLocation <EOL> self . assertEquals ( room . name , u"<STR_LIT>" ) <EOL> self . assertEquals ( room . description , u'<STR_LIT>' ) <EOL> self . assertIdentical ( iimaginary . IContainer ( room ) . getExitNamed ( u'<STR_LIT>' ) . toLocation , <EOL> self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> room = iimaginary . IContainer ( self . location ) . getExitNamed ( u'<STR_LIT>' ) . toLocation <EOL> self . assertEquals ( room . name , u"<STR_LIT>" ) <EOL> self . assertEquals ( room . description , u'<STR_LIT>' ) <EOL> self . assertIdentical ( iimaginary . IContainer ( room ) . getExitNamed ( u'<STR_LIT>' ) . toLocation , self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> def test_digWithDirectionAliases ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> room = iimaginary . IContainer ( self . location ) . getExitNamed ( u'<STR_LIT>' ) . toLocation <EOL> self . assertEquals ( room . name , u"<STR_LIT>" ) <EOL> self . assertEquals ( room . description , u'<STR_LIT>' ) <EOL> self . assertIdentical ( iimaginary . IContainer ( room ) . getExitNamed ( u'<STR_LIT>' ) . toLocation , <EOL> self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> room = iimaginary . IContainer ( self . location ) . getExitNamed ( u'<STR_LIT>' ) . toLocation <EOL> self . assertEquals ( room . name , u"<STR_LIT>" ) <EOL> self . assertEquals ( room . description , u'<STR_LIT>' ) <EOL> self . assertIdentical ( iimaginary . IContainer ( room ) . getExitNamed ( u'<STR_LIT>' ) . toLocation , self . location ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> def test_bury ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , [ ] ) <EOL> room = objects . Thing ( store = self . store , name = u"<STR_LIT>" , proper = True ) <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( room , self . location , u'<STR_LIT>' ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , <EOL> [ ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( room ) . getExits ( ) ) , <EOL> [ ] ) <EOL> objects . Exit . link ( self . location , room , u'<STR_LIT>' ) <EOL> self . observer . moveTo ( room ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , <EOL> [ ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( room ) . getExits ( ) ) , <EOL> [ ] ) <EOL> def test_buryWithDirectionAliases ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , [ ] ) <EOL> room = objects . Thing ( store = self . store , name = u"<STR_LIT>" , proper = True ) <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( room , self . location , u'<STR_LIT>' ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , <EOL> [ ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( room ) . getExits ( ) ) , <EOL> [ ] ) <EOL> objects . Exit . link ( self . location , room , u'<STR_LIT>' ) <EOL> self . observer . moveTo ( room ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( self . location ) . getExits ( ) ) , <EOL> [ ] ) <EOL> self . assertEquals ( <EOL> list ( iimaginary . IContainer ( room ) . getExits ( ) ) , <EOL> [ ] ) <EOL> def test_go ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> room = objects . Thing ( store = self . store , name = u"<STR_LIT>" ) <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( self . location , room , u"<STR_LIT>" ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> def test_goThroughDirectionAliases ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT:w>" , <EOL> [ "<STR_LIT>" ] ) <EOL> room = objects . Thing ( store = self . store , name = u"<STR_LIT>" ) <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( self . location , room , u"<STR_LIT>" ) <EOL> self . _test ( <EOL> "<STR_LIT:w>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT:n>" , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> def test_goThroughOneWayExit ( self ) : <EOL> """<STR_LIT>""" <EOL> secretRoom = objects . Thing ( store = self . store , name = u'<STR_LIT>' ) <EOL> objects . Container . createFor ( secretRoom , capacity = <NUM_LIT:1000> ) <EOL> myExit = objects . Exit ( store = self . store , fromLocation = secretRoom , <EOL> toLocation = self . location , name = u'<STR_LIT>' ) <EOL> self . player . moveTo ( secretRoom ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . player . moveTo ( secretRoom ) <EOL> myExit . name = u'<STR_LIT>' <EOL> self . assertCommandOutput ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> def test_goDoesntJumpOverExits ( self ) : <EOL> """<STR_LIT>""" <EOL> northRoom = objects . Thing ( store = self . store , name = u'<STR_LIT>' ) <EOL> eastRoom = objects . Thing ( store = self . store , name = u'<STR_LIT>' ) <EOL> for room in northRoom , eastRoom : <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( self . location , northRoom , u'<STR_LIT>' , distance = <NUM_LIT:0.1> ) <EOL> objects . Exit . link ( northRoom , eastRoom , u'<STR_LIT>' , distance = <NUM_LIT:0.1> ) <EOL> self . assertCommandOutput ( "<STR_LIT>" , [ E ( "<STR_LIT>" ) ] , [ ] ) <EOL> def test_directionalMovement ( self ) : <EOL> """<STR_LIT>""" <EOL> self . observer . location = None <EOL> self . location . description = None <EOL> oldRoom = self . location <EOL> allDirections = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> for d in allDirections [ : len ( allDirections ) / <NUM_LIT:2> ] : <EOL> room = objects . Thing ( store = self . store , name = u"<STR_LIT>" ) <EOL> objects . Container . createFor ( room , capacity = <NUM_LIT:1000> ) <EOL> objects . Exit . link ( oldRoom , room , unicode ( d , '<STR_LIT:ascii>' ) ) <EOL> oldRoom = room <EOL> for d , rd in zip ( allDirections , reversed ( allDirections ) ) : <EOL> self . _test ( <EOL> d , <EOL> [ E ( "<STR_LIT>" ) + "<STR_LIT>" + E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) + "<STR_LIT>" + E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" ] ) <EOL> shortDirections = [ "<STR_LIT>" , "<STR_LIT:n>" , "<STR_LIT>" , "<STR_LIT:e>" , "<STR_LIT:w>" , "<STR_LIT>" , "<STR_LIT:s>" , "<STR_LIT>" ] <EOL> for d , rd in zip ( shortDirections , reversed ( shortDirections ) ) : <EOL> self . _test ( <EOL> d , <EOL> [ E ( "<STR_LIT>" ) + "<STR_LIT>" + E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) + "<STR_LIT>" + E ( "<STR_LIT>" ) , <EOL> "<STR_LIT>" ] ) <EOL> def test_scrutinize ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) + STOREID + E ( "<STR_LIT>" ) + PTR <EOL> + E ( "<STR_LIT:U+002C>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" <EOL> "<STR_LIT>" ) + <EOL> STOREID + E ( "<STR_LIT>" <EOL> "<STR_LIT>" ) + <EOL> STOREID + E ( "<STR_LIT>" ) + PTR + E ( "<STR_LIT:U+002C>" ) , <EOL> E ( "<STR_LIT>" <EOL> "<STR_LIT>" ) + <EOL> STOREID + E ( "<STR_LIT>" <EOL> "<STR_LIT>" ) + <EOL> STOREID + E ( "<STR_LIT>" ) + PTR + E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) , <EOL> E ( "<STR_LIT>" ) ] ) <EOL> def test_scrutinizeNonContainer ( self ) : <EOL> """<STR_LIT>""" <EOL> o = objects . Thing ( store = self . store , name = u"<STR_LIT:foo>" ) <EOL> iimaginary . IContainer ( self . location ) . add ( o ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) + <EOL> STOREID + E ( "<STR_LIT>" ) + PTR + E ( "<STR_LIT:U+002C>" ) , <EOL> E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" ) , <EOL> E ( u"<STR_LIT>" ) ] ) <EOL> def testOpenClose ( self ) : <EOL> container = objects . Thing ( store = self . store , name = u"<STR_LIT>" ) <EOL> objects . Container . createFor ( container , capacity = <NUM_LIT:1> ) <EOL> iimaginary . IContainer ( self . location ) . add ( container ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ "<STR_LIT>" ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ ] ) <EOL> def test_invalidHelp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ ] ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> [ "<STR_LIT>" ] , <EOL> [ ] ) <EOL> def test_help ( self ) : <EOL> """<STR_LIT>""" <EOL> resources = filepath . FilePath ( __file__ ) . parent ( ) . sibling ( "<STR_LIT>" ) <EOL> self . _test ( <EOL> "<STR_LIT>" , <EOL> resources . child ( "<STR_LIT>" ) . child ( "<STR_LIT>" ) . getContent ( ) . splitlines ( ) , <EOL> [ ] ) <EOL> def test_helpMultiword ( self ) : <EOL> """<STR_LIT>""" <EOL> fakeHelp = filepath . FilePath ( self . mktemp ( ) ) <EOL> fakeHelp . makedirs ( ) <EOL> fakeHelp . child ( "<STR_LIT>" ) . setContent ( "<STR_LIT>" ) <EOL> original = Help . helpContentPath <EOL> try : <EOL> Help . helpContentPath = fakeHelp <EOL> self . _test ( "<STR_LIT>" , [ "<STR_LIT>" ] , [ ] ) <EOL> finally : <EOL> Help . helpContentPath = original </s>
