Skip to content

Commit 3528a79

Browse files
committed
Update the test name displayed in the latest_logs info file
1 parent 4bba532 commit 3528a79

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

seleniumbase/core/log_helper.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,45 @@ def log_page_source(test_logpath, driver, source=None):
136136

137137

138138
def get_test_id(test):
139-
test_id = "%s.%s.%s" % (
140-
test.__class__.__module__,
141-
test.__class__.__name__,
142-
test._testMethodName)
143-
if test._sb_test_identifier and len(str(test._sb_test_identifier)) > 6:
144-
test_id = test._sb_test_identifier
139+
test_id = None
140+
try:
141+
test_id = get_test_name(test)
142+
except Exception:
143+
test_id = "%s.%s.%s" % (
144+
test.__class__.__module__,
145+
test.__class__.__name__,
146+
test._testMethodName)
147+
if test._sb_test_identifier and len(str(test._sb_test_identifier)) > 6:
148+
test_id = test._sb_test_identifier
145149
return test_id
146150

147151

152+
def get_test_name(test):
153+
if test.is_pytest:
154+
test_name = "%s.py::%s::%s" % (
155+
test.__class__.__module__.split('.')[-1],
156+
test.__class__.__name__,
157+
test._testMethodName)
158+
else:
159+
test_name = "%s.py:%s.%s" % (
160+
test.__class__.__module__.split('.')[-1],
161+
test.__class__.__name__,
162+
test._testMethodName)
163+
if test._sb_test_identifier and len(str(test._sb_test_identifier)) > 6:
164+
test_name = test._sb_test_identifier
165+
if hasattr(test, "_using_sb_fixture_class"):
166+
if test_name.count('.') >= 2:
167+
parts = test_name.split('.')
168+
full = parts[-3] + '.py::' + parts[-2] + '::' + parts[-1]
169+
test_name = full
170+
elif hasattr(test, "_using_sb_fixture_no_class"):
171+
if test_name.count('.') >= 1:
172+
parts = test_name.split('.')
173+
full = parts[-2] + '.py::' + parts[-1]
174+
test_name = full
175+
return test_name
176+
177+
148178
def get_last_page(driver):
149179
try:
150180
last_page = driver.current_url

0 commit comments

Comments
 (0)