MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / __get_test_id

Method __get_test_id

seleniumbase/fixtures/base_case.py:16517–16568  ·  view source on GitHub ↗

The id used in various places such as the test log path.

(self)

Source from the content-addressed store, hash-verified

16515 return has_exception
16516
16517 def __get_test_id(self):
16518 """The id used in various places such as the test log path."""
16519 if getattr(self, "is_behave", None):
16520 file_name = sb_config.behave_scenario.filename
16521 file_name = file_name.replace("/", ".").replace("\\", ".")
16522 scenario_name = sb_config.behave_scenario.name
16523 if " -- @" in scenario_name:
16524 scenario_name = scenario_name.split(" # ")[0].rstrip()
16525 scenario_name = re.sub(r"[^\w" + r"_ " + r"]", "", scenario_name)
16526 scenario_name = scenario_name.replace(" ", "_")
16527 test_id = "%s.%s" % (file_name, scenario_name)
16528 return test_id
16529 elif getattr(self, "is_context_manager", None):
16530 if hasattr(self, "_manager_saved_id"):
16531 self.__saved_id = self._manager_saved_id
16532 if self.__saved_id:
16533 return self.__saved_id
16534 filename = self.__class__.__module__.split(".")[-1] + ".py"
16535 methodname = self._testMethodName
16536 context_id = None
16537 if filename == "base_case.py" or methodname == "runTest":
16538 import traceback
16539 stack_base = traceback.format_stack()[0].split(os.sep)[-1]
16540 test_base = stack_base.split(", in ")[0]
16541 if getattr(self, "cm_filename", None):
16542 filename = self.cm_filename
16543 else:
16544 filename = test_base.split('"')[0]
16545 methodname = ".line_" + test_base.split(", line ")[-1]
16546 context_id = filename.split(".")[0] + methodname
16547 self.__saved_id = context_id
16548 return context_id
16549 test_id = "%s.%s.%s" % (
16550 self.__class__.__module__,
16551 self.__class__.__name__,
16552 self._testMethodName,
16553 )
16554 if self._sb_test_identifier and len(str(self._sb_test_identifier)) > 6:
16555 test_id = self._sb_test_identifier
16556 elif getattr(self, "_using_sb_fixture", None):
16557 test_id = sb_config._latest_display_id
16558 test_id = test_id.replace(".py::", ".").replace("::", ".")
16559 test_id = test_id.replace("/", ".").replace("\\", ".")
16560 test_id = test_id.replace(" ", "_")
16561 # Linux filename length limit for `open(filename)` = 255
16562 # 255 - len("latest_logs/") - len("/basic_test_info.txt") = 223
16563 if len(test_id) <= 223:
16564 return test_id
16565 else:
16566 # 223 - len("__TRUNCATED__") = 210
16567 # 210 / 2 = 105
16568 return test_id[:105] + "__TRUNCATED__" + test_id[-105:]
16569
16570 def __get_test_id_2(self):
16571 """The id for SeleniumBase Dashboard entries."""

Callers 14

get_new_driverMethod · 0.95
save_as_pdf_to_logsMethod · 0.95
save_data_to_logsMethod · 0.95
append_data_to_logsMethod · 0.95
skipMethod · 0.95
check_windowMethod · 0.95
setUpMethod · 0.95
__get_test_id_2Method · 0.95
__process_dashboardMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected