<s> """<STR_LIT>""" <EOL> import py <EOL> def pytest_addoption ( parser ) : <EOL> group = parser . addgroup ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> group . addoption ( '<STR_LIT>' , action = "<STR_LIT:store>" , dest = "<STR_LIT>" , metavar = "<STR_LIT:path>" , default = None , <EOL> help = "<STR_LIT>" ) <EOL> def pytest_configure ( config ) : <EOL> resultlog = config . option . resultlog <EOL> if resultlog : <EOL> logfile = open ( resultlog , '<STR_LIT:w>' , <NUM_LIT:1> ) <EOL> config . _resultlog = ResultLog ( config , logfile ) <EOL> config . pluginmanager . register ( config . _resultlog ) <EOL> def pytest_unconfigure ( config ) : <EOL> resultlog = getattr ( config , '<STR_LIT>' , None ) <EOL> if resultlog : <EOL> resultlog . logfile . close ( ) <EOL> del config . _resultlog <EOL> config . pluginmanager . unregister ( resultlog ) <EOL> def generic_path ( item ) : <EOL> chain = item . listchain ( ) <EOL> gpath = [ chain [ <NUM_LIT:0> ] . name ] <EOL> fspath = chain [ <NUM_LIT:0> ] . fspath <EOL> fspart = False <EOL> for node in chain [ <NUM_LIT:1> : ] : <EOL> newfspath = node . fspath <EOL> if newfspath == fspath : <EOL> if fspart : <EOL> gpath . append ( '<STR_LIT::>' ) <EOL> fspart = False <EOL> else : <EOL> gpath . append ( '<STR_LIT:.>' ) <EOL> else : <EOL> gpath . append ( '<STR_LIT:/>' ) <EOL> fspart = True <EOL> name = node . name <EOL> if name [ <NUM_LIT:0> ] in '<STR_LIT>' : <EOL> gpath . pop ( ) <EOL> gpath . append ( name ) <EOL> fspath = newfspath <EOL> return '<STR_LIT>' . join ( gpath ) <EOL> class ResultLog ( object ) : <EOL> def __init__ ( self , config , logfile ) : <EOL> self . config = config <EOL> self . logfile = logfile <EOL> def write_log_entry ( self , testpath , shortrepr , longrepr ) : <EOL> print >> self . logfile , "<STR_LIT>" % ( shortrepr , testpath ) <EOL> for line in longrepr . splitlines ( ) : <EOL> print >> self . logfile , "<STR_LIT>" % line <EOL> def log_outcome ( self , node , shortrepr , longrepr ) : <EOL> testpath = generic_path ( node ) <EOL> self . write_log_entry ( testpath , shortrepr , longrepr ) <EOL> def pytest_runtest_logreport ( self , report ) : <EOL> res = self . config . hook . pytest_report_teststatus ( report = report ) <EOL> if res is not None : <EOL> code = res [ <NUM_LIT:1> ] <EOL> else : <EOL> code = report . shortrepr <EOL> if code == '<STR_LIT:x>' : <EOL> longrepr = str ( report . longrepr ) <EOL> elif code == '<STR_LIT:P>' : <EOL> longrepr = '<STR_LIT>' <EOL> elif report . passed : <EOL> longrepr = "<STR_LIT>" <EOL> elif report . failed : <EOL> longrepr = str ( report . longrepr ) <EOL> elif report . skipped : <EOL> longrepr = str ( report . longrepr . reprcrash . message ) <EOL> self . log_outcome ( report . item , code , longrepr ) <EOL> def pytest_collectreport ( self , report ) : <EOL> if not report . passed : <EOL> if report . failed : <EOL> code = "<STR_LIT:F>" <EOL> else : <EOL> assert report . skipped <EOL> code = "<STR_LIT:S>" <EOL> longrepr = str ( report . longrepr . reprcrash ) <EOL> self . log_outcome ( report . collector , code , longrepr ) <EOL> def pytest_internalerror ( self , excrepr ) : <EOL> path = excrepr . reprcrash . path <EOL> self . write_log_entry ( path , '<STR_LIT:!>' , str ( excrepr ) ) </s>
