Skip to content

Commit 018b3be

Browse files
committed
Fix issues caused by pytest.mark.parametrize
1 parent 933bae9 commit 018b3be

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

seleniumbase/core/log_helper.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,11 @@ def get_test_id(test):
395395

396396
def get_test_name(test):
397397
if "PYTEST_CURRENT_TEST" in os.environ:
398-
test_name = os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
398+
full_name = os.environ["PYTEST_CURRENT_TEST"]
399+
if "] " in full_name:
400+
test_name = full_name.split("] ")[0] + "]"
401+
else:
402+
test_name = full_name.split(" ")[0]
399403
elif test.is_pytest:
400404
test_name = "%s.py::%s::%s" % (
401405
test.__class__.__module__.split(".")[-1],
@@ -410,16 +414,6 @@ def get_test_name(test):
410414
)
411415
if test._sb_test_identifier and len(str(test._sb_test_identifier)) > 6:
412416
test_name = test._sb_test_identifier
413-
if hasattr(test, "_using_sb_fixture_class"):
414-
if test_name.count(".") >= 2:
415-
parts = test_name.split(".")
416-
full = parts[-3] + ".py::" + parts[-2] + "::" + parts[-1]
417-
test_name = full
418-
elif hasattr(test, "_using_sb_fixture_no_class"):
419-
if test_name.count(".") >= 1:
420-
parts = test_name.split(".")
421-
full = parts[-2] + ".py::" + parts[-1]
422-
test_name = full
423417
return test_name
424418

425419

seleniumbase/fixtures/base_case.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14048,17 +14048,21 @@ def __get_test_id(self):
1404814048
if self._sb_test_identifier and len(str(self._sb_test_identifier)) > 6:
1404914049
test_id = self._sb_test_identifier
1405014050
test_id = test_id.replace(".py::", ".").replace("::", ".")
14051-
test_id = test_id.replace("/", ".")
14051+
test_id = test_id.replace("/", ".").replace(" ", "_")
1405214052
elif hasattr(self, "_using_sb_fixture") and self._using_sb_fixture:
1405314053
test_id = sb_config._latest_display_id
1405414054
test_id = test_id.replace(".py::", ".").replace("::", ".")
14055-
test_id = test_id.replace("/", ".")
14055+
test_id = test_id.replace("/", ".").replace(" ", "_")
1405614056
return test_id
1405714057

1405814058
def __get_test_id_2(self):
1405914059
"""The id for SeleniumBase Dashboard entries."""
1406014060
if "PYTEST_CURRENT_TEST" in os.environ:
14061-
return os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
14061+
full_name = os.environ["PYTEST_CURRENT_TEST"]
14062+
if "] " in full_name:
14063+
return full_name.split("] ")[0] + "]"
14064+
else:
14065+
return full_name.split(" ")[0]
1406214066
if hasattr(self, "is_behave") and self.is_behave:
1406314067
return self.__get_test_id()
1406414068
test_id = "%s.%s.%s" % (
@@ -14075,7 +14079,11 @@ def __get_test_id_2(self):
1407514079
def __get_display_id(self):
1407614080
"""The id for running a test from pytest. (Displayed on Dashboard)"""
1407714081
if "PYTEST_CURRENT_TEST" in os.environ:
14078-
return os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
14082+
full_name = os.environ["PYTEST_CURRENT_TEST"]
14083+
if "] " in full_name:
14084+
return full_name.split("] ")[0] + "]"
14085+
else:
14086+
return full_name.split(" ")[0]
1407914087
if hasattr(self, "is_behave") and self.is_behave:
1408014088
file_name = sb_config.behave_scenario.filename
1408114089
line_num = sb_config.behave_line_num
@@ -14222,6 +14230,7 @@ def __process_dashboard(self, has_exception, init=False):
1422214230
alt_test_id = sb_config._display_id[test_id]
1422314231
alt_test_id = alt_test_id.replace(".py::", ".")
1422414232
alt_test_id = alt_test_id.replace("::", ".")
14233+
alt_test_id = alt_test_id.replace(" ", "_")
1422514234
if alt_test_id in sb_config._results.keys():
1422614235
sb_config._results.pop(alt_test_id)
1422714236
if test_id in sb_config._results.keys() and (

0 commit comments

Comments
 (0)