@@ -672,6 +672,7 @@ def pytest_collection_finish(session):
672
672
Print the dashboard path if at least one test runs.
673
673
https://docs.pytest.org/en/stable/reference.html """
674
674
if sb_config .dashboard and len (session .items ) > 0 :
675
+ sb_config .item_count_untested = sb_config .item_count
675
676
dash_path = os .getcwd () + "/dashboard.html"
676
677
star_len = len ("Dashboard: " ) + len (dash_path )
677
678
try :
@@ -765,49 +766,57 @@ def pytest_unconfigure():
765
766
find_it = constants .Dashboard .META_REFRESH_HTML
766
767
swap_with = '' # Stop refreshing the page after the run is done
767
768
try :
768
- # Part 1: Finalizing the dashboard / integrating html report
769
- time .sleep (0.3 ) # Add time for "livejs" to detect changes
770
769
abs_path = os .path .abspath ('.' )
771
770
dashboard_path = os .path .join (abs_path , "dashboard.html" )
771
+ # Part 1: Finalizing the dashboard / integrating html report
772
772
if os .path .exists (dashboard_path ):
773
+ the_html_d = None
773
774
with open (dashboard_path , 'r' , encoding = 'utf-8' ) as f :
774
- the_html = f .read ()
775
+ the_html_d = f .read ()
775
776
# If the test run doesn't complete by itself, stop refresh
776
- the_html = the_html .replace (find_it , swap_with )
777
- the_html += stamp
777
+ the_html_d = the_html_d .replace (find_it , swap_with )
778
+ the_html_d += stamp
778
779
if sb_config ._dash_is_html_report and (
779
780
sb_config ._saved_dashboard_pie ):
780
- the_html = the_html .replace (
781
+ the_html_d = the_html_d .replace (
781
782
"<h1>dashboard.html</h1>" ,
782
783
sb_config ._saved_dashboard_pie )
783
- the_html = the_html .replace (
784
+ the_html_d = the_html_d .replace (
784
785
"</head>" , '</head><link rel="shortcut icon" '
785
786
'href="https://seleniumbase.io/img/dash_pie_2.png">' )
786
787
if sb_config ._dash_final_summary :
787
- the_html += sb_config ._dash_final_summary
788
- time .sleep (0.25 )
788
+ the_html_d += sb_config ._dash_final_summary
789
+ with open (dashboard_path , "w" , encoding = 'utf-8' ) as f :
790
+ f .write (the_html_d ) # Finalize the dashboard
791
+ time .sleep (0.5 ) # Add time for "livejs" to detect changes
792
+ the_html_d = the_html_d .replace (
793
+ "</head>" , "</head><!-- Dashboard Report Done -->" )
789
794
with open (dashboard_path , "w" , encoding = 'utf-8' ) as f :
790
- f .write (the_html )
791
- # Part 2: Appending a pytest html report with dashboard data
792
- html_report_path = os .path .join (
793
- abs_path , sb_config ._html_report_name )
794
- if sb_config ._using_html_report and (
795
- os .path .exists (html_report_path ) and
796
- not sb_config ._dash_is_html_report ):
797
- # Add the dashboard pie to the pytest html report
798
- with open (html_report_path , 'r' , encoding = 'utf-8' ) as f :
799
- the_html = f .read ()
800
- if sb_config ._saved_dashboard_pie :
801
- the_html = the_html .replace (
802
- "<h1>%s</h1>" % sb_config ._html_report_name ,
803
- sb_config ._saved_dashboard_pie )
804
- the_html = the_html .replace (
805
- "</head>" , '</head><link rel="shortcut icon" '
806
- 'href="https://seleniumbase.io/img/dash_pie_2.png">' )
807
- if sb_config ._dash_final_summary :
808
- the_html += sb_config ._dash_final_summary
809
- with open (html_report_path , "w" , encoding = 'utf-8' ) as f :
810
- f .write (the_html )
795
+ f .write (the_html_d ) # Finalize the dashboard
796
+ # Part 2: Appending a pytest html report with dashboard data
797
+ html_report_path = None
798
+ if sb_config ._html_report_name :
799
+ html_report_path = os .path .join (
800
+ abs_path , sb_config ._html_report_name )
801
+ if sb_config ._using_html_report and html_report_path and (
802
+ os .path .exists (html_report_path ) and
803
+ not sb_config ._dash_is_html_report ):
804
+ # Add the dashboard pie to the pytest html report
805
+ the_html_r = None
806
+ with open (html_report_path , 'r' , encoding = 'utf-8' ) as f :
807
+ the_html_r = f .read ()
808
+ if sb_config ._saved_dashboard_pie :
809
+ the_html_r = the_html_r .replace (
810
+ "<h1>%s</h1>" % sb_config ._html_report_name ,
811
+ sb_config ._saved_dashboard_pie )
812
+ the_html_r = the_html_r .replace (
813
+ "</head>" , '</head><link rel="shortcut icon" '
814
+ 'href='
815
+ '"https://seleniumbase.io/img/dash_pie_2.png">' )
816
+ if sb_config ._dash_final_summary :
817
+ the_html_r += sb_config ._dash_final_summary
818
+ with open (html_report_path , "w" , encoding = 'utf-8' ) as f :
819
+ f .write (the_html_r ) # Finalize the HTML report
811
820
except Exception :
812
821
pass
813
822
0 commit comments