#NEWLINE# def run_tests( test_labels , verbosity = 1 , interactive = True , extra_tests = [ ] , nodatabase = False , xml_out = False , callgraph = False , html_only = False ) : #NEWLINE# #INDENT# '\n    Test runner which displays a code coverage report at the end of the\n    run.\n    ' #NEWLINE# cov = coverage . coverage ( ) #NEWLINE# cov . erase ( ) #NEWLINE# cov . use_cache ( 0 ) #NEWLINE# test_labels = ( test_labels or getattr ( settings , 'TEST_APPS' , None ) ) #NEWLINE# cover_branch = getattr ( settings , 'COVERAGE_BRANCH_COVERAGE' , False ) #NEWLINE# cov = coverage . coverage ( branch = cover_branch , cover_pylib = False ) #NEWLINE# cov . use_cache ( 0 ) #NEWLINE# coverage_modules = [ ] #NEWLINE# if test_labels : #NEWLINE# #INDENT# for label in test_labels : #NEWLINE# #INDENT# if ( '.' not in label ) : #NEWLINE# #INDENT# app = get_app ( label ) #NEWLINE# coverage_modules . extend ( get_all_coverage_modules ( app ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# for app in get_apps ( ) : #NEWLINE# #INDENT# coverage_modules . extend ( get_all_coverage_modules ( app ) ) #NEWLINE# #UNINDENT# #UNINDENT# morfs = filter ( is_wanted_module , coverage_modules ) #NEWLINE# if callgraph : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# import pycallgraph #NEWLINE# _included = getattr ( settings , 'COVERAGE_INCLUDE_MODULES' , [ ] ) #NEWLINE# _excluded = getattr ( settings , 'COVERAGE_EXCLUDE_MODULES' , [ ] ) #NEWLINE# _included = [ ( i . strip ( '*' ) + '*' ) for i in _included ] #NEWLINE# _excluded = [ ( i . strip ( '*' ) + '*' ) for i in _included ] #NEWLINE# _filter_func = pycallgraph . GlobbingFilter ( include = ( _included or [ '*' ] ) ) #NEWLINE# pycallgraph_enabled = True #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# pycallgraph_enabled = False #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# pycallgraph_enabled = False #NEWLINE# #UNINDENT# cov . start ( ) #NEWLINE# if pycallgraph_enabled : #NEWLINE# #INDENT# pycallgraph . start_trace ( filter_func = _filter_func ) #NEWLINE# #UNINDENT# if nodatabase : #NEWLINE# #INDENT# results = nodatabase_run_tests ( test_labels , verbosity , interactive , extra_tests ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# results = django_test_runner ( test_labels , verbosity , interactive , extra_tests ) #NEWLINE# #UNINDENT# if ( callgraph and pycallgraph_enabled ) : #NEWLINE# #INDENT# pycallgraph . stop_trace ( ) #NEWLINE# #UNINDENT# cov . stop ( ) #NEWLINE# if ( getattr ( settings , 'COVERAGE_HTML_REPORT' , False ) or os . environ . get ( 'COVERAGE_HTML_REPORT' ) ) : #NEWLINE# #INDENT# output_dir = getattr ( settings , 'COVERAGE_HTML_DIRECTORY' , 'covhtml' ) #NEWLINE# report_method = curry ( cov . html_report , directory = output_dir ) #NEWLINE# if ( callgraph and pycallgraph_enabled ) : #NEWLINE# #INDENT# callgraph_path = ( ( report_method + '/' ) + 'callgraph.png' ) #NEWLINE# pycallgraph . make_dot_graph ( callgraph_path ) #NEWLINE# #UNINDENT# ( print >> sys . stdout ) #NEWLINE# ( ( print >> sys . stdout ) , ( "Coverage HTML reports were output to '%s'" % output_dir ) ) #NEWLINE# if callgraph : #NEWLINE# #INDENT# if pycallgraph_enabled : #NEWLINE# #INDENT# ( ( print >> sys . stdout ) , ( "Call graph was output to '%s'" % callgraph_path ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( ( print >> sys . stdout ) , "Call graph was not generated: Install 'pycallgraph' module to do so" ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# report_method = cov . report #NEWLINE# #UNINDENT# if coverage_modules : #NEWLINE# #INDENT# if xml_out : #NEWLINE# #INDENT# if ( not os . path . isdir ( os . path . join ( 'temp' , 'xml' ) ) ) : #NEWLINE# #INDENT# os . makedirs ( os . path . join ( 'temp' , 'xml' ) ) #NEWLINE# #UNINDENT# output_filename = 'temp/xml/coverage_output.xml' #NEWLINE# cov . xml_report ( morfs = coverage_modules , outfile = output_filename ) #NEWLINE# #UNINDENT# if ( not html_only ) : #NEWLINE# #INDENT# cov . report ( coverage_modules , show_missing = 1 ) #NEWLINE# #UNINDENT# #UNINDENT# return results