4
4
import colorama
5
5
import os
6
6
import pytest
7
- import re
8
7
import sys
9
8
import time
10
9
from seleniumbase import config as sb_config
@@ -967,6 +966,7 @@ def pytest_configure(config):
967
966
sb_config .item_count_skipped = 0
968
967
sb_config .item_count_untested = 0
969
968
sb_config .is_pytest = True
969
+ sb_config .pytest_config = config
970
970
sb_config .browser = config .getoption ("browser" )
971
971
if sb_config ._browser_shortcut :
972
972
sb_config .browser = sb_config ._browser_shortcut
@@ -1129,10 +1129,16 @@ def pytest_sessionstart(session):
1129
1129
1130
1130
1131
1131
def _get_test_ids_ (the_item ):
1132
- test_id = the_item .nodeid . split ( "/" )[ - 1 ]
1132
+ test_id = the_item .nodeid
1133
1133
if not test_id :
1134
1134
test_id = "unidentified_TestCase"
1135
- test_id = test_id .replace (" " , "_" )
1135
+ display_id = test_id
1136
+ r"""
1137
+ # Due to changes in SeleniumBase 1.66.0, we're now using the
1138
+ # item's original nodeid for both the test_id and display_id.
1139
+ # (This only impacts tests using The Dashboard.)
1140
+ # If there are any issues, we'll revert back to the old code.
1141
+ test_id = the_item.nodeid.split("/")[-1].replace(" ", "_")
1136
1142
if "[" in test_id:
1137
1143
test_id_intro = test_id.split("[")[0]
1138
1144
parameter = test_id.split("[")[1]
@@ -1141,12 +1147,13 @@ def _get_test_ids_(the_item):
1141
1147
display_id = test_id
1142
1148
test_id = test_id.replace("/", ".").replace("\\", ".")
1143
1149
test_id = test_id.replace("::", ".").replace(".py", "")
1150
+ """
1144
1151
return test_id , display_id
1145
1152
1146
1153
1147
1154
def _create_dashboard_assets_ ():
1148
1155
import codecs
1149
- from seleniumbase .core . js_snippets import live_js
1156
+ from seleniumbase .js_code . live_js import live_js
1150
1157
from seleniumbase .core .style_sheet import pytest_style
1151
1158
1152
1159
abs_path = os .path .abspath ("." )
@@ -1292,6 +1299,14 @@ def pytest_terminal_summary(terminalreporter):
1292
1299
1293
1300
def pytest_unconfigure ():
1294
1301
""" This runs after all tests have completed with pytest. """
1302
+ if (
1303
+ hasattr (sb_config , "_dash_html_for_multithreading" )
1304
+ and sb_config ._multithreaded
1305
+ ):
1306
+ abs_path = os .path .abspath ("." )
1307
+ dashboard_path = os .path .join (abs_path , "dashboard.html" )
1308
+ with open (dashboard_path , "w" , encoding = "utf-8" ) as f :
1309
+ f .write (sb_config ._dash_html )
1295
1310
proxy_helper .remove_proxy_zip_if_present ()
1296
1311
if hasattr (sb_config , "reuse_session" ) and sb_config .reuse_session :
1297
1312
# Close the shared browser session
@@ -1336,7 +1351,7 @@ def pytest_unconfigure():
1336
1351
swap_with = "" # Stop refreshing the page after the run is done
1337
1352
find_it_2 = "Awaiting results... (Refresh the page for updates)"
1338
1353
swap_with_2 = (
1339
- "Test Run ENDED: Some results UNREPORTED due to skipped tearDown! "
1354
+ "Test Run ENDED: Some results UNREPORTED due to skipped tearDown() "
1340
1355
)
1341
1356
find_it_3 = '<td class="col-result">Untested</td>'
1342
1357
swap_with_3 = '<td class="col-result">Unreported</td>'
@@ -1525,14 +1540,20 @@ def pytest_runtest_makereport(item, call):
1525
1540
test_id = item .nodeid
1526
1541
if not test_id :
1527
1542
test_id = "unidentified_TestCase"
1528
- test_id = test_id .replace (" " , "_" )
1543
+ r"""
1544
+ # Due to changes in SeleniumBase 1.66.0, we're now using the
1545
+ # item's original nodeid for both the test_id and display_id.
1546
+ # (This only impacts tests using The Dashboard.)
1547
+ # If there are any issues, we'll revert back to the old code.
1548
+ test_id = test_id.split("/")[-1].replace(" ", "_")
1529
1549
if "[" in test_id:
1530
1550
test_id_intro = test_id.split("[")[0]
1531
1551
parameter = test_id.split("[")[1]
1532
1552
parameter = re.sub(re.compile(r"\W"), "", parameter)
1533
1553
test_id = test_id_intro + "__" + parameter
1534
1554
test_id = test_id.replace("/", ".").replace("\\", ".")
1535
1555
test_id = test_id.replace("::", ".").replace(".py", "")
1556
+ """
1536
1557
sb_node ._sb_test_identifier = test_id
1537
1558
if sb_node ._needs_tearDown :
1538
1559
sb_node .tearDown ()
0 commit comments