<s> """<STR_LIT>""" <EOL> import datetime <EOL> import logging <EOL> import unittest <EOL> import ast <EOL> from bson . objectid import ObjectId <EOL> import tornado . testing <EOL> import motor <EOL> import twcommon . misc <EOL> import two . execute <EOL> import two . symbols <EOL> import two . task <EOL> from two . execute import EvalPropContext <EOL> from twcommon . excepts import SymbolError <EOL> import twest . mock <EOL> from twest . mock import NotFound <EOL> class TestEvalAsync ( twest . mock . MockAppTestCase ) : <EOL> mockappargs = { '<STR_LIT>' : True , '<STR_LIT>' : True } <EOL> @ tornado . gen . coroutine <EOL> def resetTables ( self ) : <EOL> self . exuid = ObjectId ( ) <EOL> self . exwid = ObjectId ( ) <EOL> self . exiid = ObjectId ( ) <EOL> self . exlocid = ObjectId ( ) <EOL> self . exscid = ObjectId ( ) <EOL> self . loctx = two . task . LocContext ( <EOL> uid = self . exuid , wid = self . exwid , scid = self . exscid , <EOL> iid = self . exiid , locid = self . exlocid ) <EOL> yield motor . Op ( self . app . mongodb . worldprop . remove , <EOL> { } ) <EOL> yield motor . Op ( self . app . mongodb . worldprop . insert , <EOL> { '<STR_LIT>' : self . exwid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:x>' , '<STR_LIT>' : <NUM_LIT:0> } ) <EOL> yield motor . Op ( self . app . mongodb . worldprop . insert , <EOL> { '<STR_LIT>' : self . exwid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:w>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> yield motor . Op ( self . app . mongodb . worldprop . insert , <EOL> { '<STR_LIT>' : self . exwid , '<STR_LIT>' : None , <EOL> '<STR_LIT:key>' : '<STR_LIT:r>' , '<STR_LIT>' : <NUM_LIT:11> } ) <EOL> yield motor . Op ( self . app . mongodb . worldprop . insert , <EOL> { '<STR_LIT>' : self . exwid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:r>' , '<STR_LIT>' : <NUM_LIT:12> } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . remove , <EOL> { } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:x>' , '<STR_LIT>' : <NUM_LIT:1> } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:y>' , '<STR_LIT>' : <NUM_LIT:2> } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , '<STR_LIT>' : [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT>' , '<STR_LIT>' : { '<STR_LIT>' : <NUM_LIT:1> , '<STR_LIT>' : <NUM_LIT:2> , '<STR_LIT>' : <NUM_LIT:3> } } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : None , <EOL> '<STR_LIT:key>' : '<STR_LIT:r>' , '<STR_LIT>' : <NUM_LIT> } ) <EOL> yield motor . Op ( self . app . mongodb . instanceprop . insert , <EOL> { '<STR_LIT>' : self . exiid , '<STR_LIT>' : self . exlocid , <EOL> '<STR_LIT:key>' : '<STR_LIT:r>' , '<STR_LIT>' : <NUM_LIT> } ) <EOL> @ tornado . testing . gen_test <EOL> def test_global_funcs ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:3> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:3> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:3> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:6> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:6> , <NUM_LIT:7> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:6> , <NUM_LIT:7> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:6> : <NUM_LIT:7> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ { '<STR_LIT:type>' : '<STR_LIT:text>' , '<STR_LIT:text>' : '<STR_LIT:x>' } ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ { '<STR_LIT:type>' : '<STR_LIT:code>' , '<STR_LIT:text>' : '<STR_LIT:x>' } ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:text>' : '<STR_LIT:x>' } ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ObjectId ( "<STR_LIT>" ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertFalse ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertFalse ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertFalse ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertFalse ( res ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( isinstance ( res , two . execute . RealmProxy ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( isinstance ( res , two . execute . WorldLocationsProxy ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( isinstance ( res , two . execute . PlayerProxy ) ) <EOL> self . assertEqual ( res , self . exuid ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertIn ( res , [ "<STR_LIT:X>" , "<STR_LIT:Y>" , "<STR_LIT>" ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertIn ( res , [ <NUM_LIT:4> , <NUM_LIT:5> , <NUM_LIT:6> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertIn ( res , [ <NUM_LIT:0> , <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertIn ( res , [ <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> @ tornado . testing . gen_test <EOL> def test_type_methods_list ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:2> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:1> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:4> , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:3> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> task . resetticks ( ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ - <NUM_LIT:1> , - <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:4> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ - <NUM_LIT:1> , - <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT:4> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:4> , <NUM_LIT:2> , - <NUM_LIT:3> , - <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:4> , <NUM_LIT:2> , - <NUM_LIT:3> , - <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ - <NUM_LIT:1> , <NUM_LIT:2> , - <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ - <NUM_LIT:1> , <NUM_LIT:2> , - <NUM_LIT:3> , <NUM_LIT:4> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:4> , - <NUM_LIT:3> , <NUM_LIT:2> , - <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:4> , - <NUM_LIT:3> , <NUM_LIT:2> , - <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ '<STR_LIT:A>' , '<STR_LIT:b>' , '<STR_LIT:C>' , '<STR_LIT:d>' ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:p>' , '<STR_LIT:d>' , '<STR_LIT:q>' ] ) <EOL> with self . assertRaises ( TypeError ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , locals = { '<STR_LIT:foo>' : open } , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( TypeError ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , locals = { '<STR_LIT:foo>' : <NUM_LIT> } , evaltype = EVALTYPE_CODE ) <EOL> @ tornado . testing . gen_test <EOL> def test_type_methods_dict ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:1> : <NUM_LIT:11> , <NUM_LIT:2> : <NUM_LIT> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:1> : <NUM_LIT:4> , <NUM_LIT:2> : <NUM_LIT:4> , <NUM_LIT:3> : <NUM_LIT:4> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ ( <NUM_LIT:1> , <NUM_LIT:11> ) ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:1> ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:1> : <NUM_LIT:11> , <NUM_LIT:3> : <NUM_LIT> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ( <NUM_LIT:1> , <NUM_LIT:11> ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , { <NUM_LIT:1> : <NUM_LIT:11> , <NUM_LIT:2> : <NUM_LIT> , <NUM_LIT:3> : <NUM_LIT> } ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ <NUM_LIT:11> ] ) <EOL> @ tornado . testing . gen_test <EOL> def test_type_methods_string ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:2> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , False ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , False ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , False ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , False ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ( '<STR_LIT:x>' , '<STR_LIT:U+002C>' , '<STR_LIT>' ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:2> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:2> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ( '<STR_LIT>' , '<STR_LIT:U+002C>' , '<STR_LIT:z>' ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , [ '<STR_LIT:x>' , '<STR_LIT:y>' , '<STR_LIT:z>' ] ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , True ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT:foo>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , '<STR_LIT>' ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> with self . assertRaises ( twcommon . excepts . ExecSandboxException ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> @ tornado . testing . gen_test <EOL> def test_datetime ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( res is task . starttime ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( isinstance ( res , datetime . datetime ) ) <EOL> self . assertEqual ( res , datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:5> , day = <NUM_LIT:1> , tzinfo = datetime . timezone . utc ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . datetime ( year = <NUM_LIT> , month = <NUM_LIT:5> , day = <NUM_LIT:2> , hour = <NUM_LIT:3> , minute = <NUM_LIT:4> , second = <NUM_LIT:5> , microsecond = <NUM_LIT> , tzinfo = datetime . timezone . utc ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . year ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . month ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . day ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . hour ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . minute ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . second ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . microsecond ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . min ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . max ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , task . starttime . resolution ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertTrue ( isinstance ( res , datetime . timedelta ) ) <EOL> self . assertEqual ( res , datetime . timedelta ( ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . timedelta ( days = <NUM_LIT:1> , seconds = <NUM_LIT:2> , milliseconds = <NUM_LIT:3> ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . timedelta ( hours = <NUM_LIT:1> , minutes = <NUM_LIT:2> , weeks = <NUM_LIT:3> ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . timedelta ( ) . min ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . timedelta ( ) . max ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , datetime . timedelta ( ) . resolution ) <EOL> @ tornado . testing . gen_test <EOL> def test_partial ( self ) : <EOL> yield self . resetTables ( ) <EOL> task = two . task . Task ( self . app , None , <NUM_LIT:1> , <NUM_LIT:2> , twcommon . misc . now ( ) ) <EOL> task . set_writable ( ) <EOL> ctx = EvalPropContext ( task , loctx = self . loctx , level = LEVEL_EXECUTE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:0> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:10> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:11> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:4> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:6> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:5> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:6> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:7> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:6> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:7> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , <NUM_LIT:8> ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ObjectId ( '<STR_LIT>' ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , ObjectId ( '<STR_LIT>' ) ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , self . exlocid ) <EOL> res = yield ctx . eval ( '<STR_LIT>' , evaltype = EVALTYPE_CODE ) <EOL> self . assertEqual ( res , self . exlocid ) <EOL> with self . assertRaises ( TypeError ) : <EOL> res = yield ctx . eval ( '<STR_LIT>' , locals = { '<STR_LIT:foo>' : open } , evaltype = EVALTYPE_CODE ) <EOL> from two . evalctx import LEVEL_EXECUTE , LEVEL_DISPSPECIAL , LEVEL_DISPLAY , LEVEL_MESSAGE , LEVEL_FLAT , LEVEL_RAW <EOL> from two . evalctx import EVALTYPE_SYMBOL , EVALTYPE_RAW , EVALTYPE_CODE , EVALTYPE_TEXT </s>
