<s> """<STR_LIT>""" <EOL> from twisted . trial import unittest <EOL> from . . _observer import LogPublisher <EOL> from . . _util import formatTrace <EOL> class UtilTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_trace ( self ) : <EOL> """<STR_LIT>""" <EOL> publisher = LogPublisher ( ) <EOL> event = dict ( log_trace = [ ] ) <EOL> o1 = lambda e : None <EOL> def o2 ( e ) : <EOL> self . assertIs ( e , event ) <EOL> self . assertEqual ( <EOL> e [ "<STR_LIT>" ] , <EOL> [ <EOL> ( publisher , o1 ) , <EOL> ( publisher , o2 ) , <EOL> ] <EOL> ) <EOL> def o3 ( e ) : <EOL> self . assertIs ( e , event ) <EOL> self . assertEqual ( <EOL> e [ "<STR_LIT>" ] , <EOL> [ <EOL> ( publisher , o1 ) , <EOL> ( publisher , o2 ) , <EOL> ( publisher , o3 ) , <EOL> ] <EOL> ) <EOL> publisher . addObserver ( o1 ) <EOL> publisher . addObserver ( o2 ) <EOL> publisher . addObserver ( o3 ) <EOL> publisher ( event ) <EOL> def test_formatTrace ( self ) : <EOL> """<STR_LIT>""" <EOL> event = dict ( log_trace = [ ] ) <EOL> o1 = lambda e : None <EOL> o2 = lambda e : None <EOL> o3 = lambda e : None <EOL> o4 = lambda e : None <EOL> o5 = lambda e : None <EOL> o1 . name = "<STR_LIT>" <EOL> o2 . name = "<STR_LIT>" <EOL> o3 . name = "<STR_LIT>" <EOL> o4 . name = "<STR_LIT>" <EOL> o5 . name = "<STR_LIT>" <EOL> def testObserver ( e ) : <EOL> self . assertIs ( e , event ) <EOL> trace = formatTrace ( e [ "<STR_LIT>" ] ) <EOL> self . assertEqual ( <EOL> trace , <EOL> ( <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> u"<STR_LIT>" <EOL> ) . format ( <EOL> root = root , <EOL> o1 = o1 , o2 = o2 , o3 = o3 , o4 = o4 , o5 = o5 , <EOL> p1 = p1 , p2 = p2 , <EOL> oTest = oTest <EOL> ) <EOL> ) <EOL> oTest = testObserver <EOL> p2 = LogPublisher ( o4 ) <EOL> p1 = LogPublisher ( o2 , o3 , p2 ) <EOL> p2 . name = "<STR_LIT>" <EOL> p1 . name = "<STR_LIT>" <EOL> root = LogPublisher ( o1 , p1 , o5 , oTest ) <EOL> root . name = "<STR_LIT>" <EOL> root ( event ) </s>
