<s> from pybuilder . errors import BuildFailedException <EOL> from pybuilder . utils import render_report <EOL> from pybuilder . ci_server_interaction import test_proxy_for <EOL> class ReportsProcessor ( object ) : <EOL> def __init__ ( self , project , logger ) : <EOL> self . project = project <EOL> self . logger = logger <EOL> self . tests_failed = <NUM_LIT:0> <EOL> self . tests_executed = <NUM_LIT:0> <EOL> def process_reports ( self , reports , total_time ) : <EOL> self . reports = reports <EOL> self . total_time = total_time <EOL> for report in reports : <EOL> if not report [ '<STR_LIT:success>' ] : <EOL> self . tests_failed += <NUM_LIT:1> <EOL> self . tests_executed += <NUM_LIT:1> <EOL> @ property <EOL> def test_report ( self ) : <EOL> return { <EOL> "<STR_LIT:time>" : self . total_time . get_millis ( ) , <EOL> "<STR_LIT:success>" : self . tests_failed == <NUM_LIT:0> , <EOL> "<STR_LIT>" : self . tests_executed , <EOL> "<STR_LIT>" : self . tests_failed , <EOL> "<STR_LIT>" : self . reports <EOL> } <EOL> def write_report_and_ensure_all_tests_passed ( self ) : <EOL> self . project . write_report ( "<STR_LIT>" , render_report ( self . test_report ) ) <EOL> self . logger . info ( "<STR_LIT>" , self . tests_executed ) <EOL> if self . tests_failed : <EOL> raise BuildFailedException ( "<STR_LIT>" % ( self . tests_failed , self . tests_executed ) ) <EOL> def report_to_ci_server ( self , project ) : <EOL> for report in self . reports : <EOL> test_name = report [ '<STR_LIT:test>' ] <EOL> test_failed = report [ '<STR_LIT:success>' ] is not True <EOL> with test_proxy_for ( project ) . and_test_name ( '<STR_LIT>' % test_name ) as test : <EOL> if test_failed : <EOL> test . fails ( report [ '<STR_LIT>' ] ) </s>
