@@ -136,15 +136,45 @@ def log_page_source(test_logpath, driver, source=None):
136
136
137
137
138
138
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
145
149
return test_id
146
150
147
151
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
+
148
178
def get_last_page (driver ):
149
179
try :
150
180
last_page = driver .current_url
0 commit comments