Skip to content

Commit 733607a

Browse files
authored
Merge pull request #1787 from seleniumbase/a-few-bug-fixes
Six Bug Fixes
2 parents 933bae9 + ce2d41c commit 733607a

File tree

9 files changed

+43
-27
lines changed

9 files changed

+43
-27
lines changed

mkdocs_build/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ghp-import==2.1.0
1515
readme-renderer==37.3
1616
pymdown-extensions==9.9.2
1717
importlib-metadata==6.0.0
18-
pipdeptree==2.5.1
18+
pipdeptree==2.5.2
1919
bleach==6.0.0
2020
lunr==0.6.2
2121
nltk==3.8.1

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ commonmark==0.9.1;python_version<"3.7"
9696
markdown-it-py==2.2.0;python_version>="3.7"
9797
mdurl==0.1.2;python_version>="3.7"
9898
rich==12.6.0;python_version<"3.7"
99-
rich==13.3.1;python_version>="3.7"
99+
rich==13.3.2;python_version>="3.7"
100100

101101
# --- Testing Requirements --- #
102102
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.13.6"
2+
__version__ = "4.13.7"

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def show_no_case_plans_warning():
7171

7272
def get_test_id(display_id):
7373
"""The id used in various places such as the test log path."""
74-
return display_id.replace(".py::", ".").replace("::", ".")
74+
return (
75+
display_id.replace(".py::", ".").replace("::", ".").replace(" ", "_")
76+
)
7577

7678

7779
def generate_case_plan_boilerplates(

seleniumbase/console_scripts/sb_commander.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ def do_pytest_run(
9393
for test_number, test in enumerate(tests):
9494
if selected_tests[test_number].get():
9595
full_run_command += " "
96-
full_run_command += test
96+
if ' ' not in test:
97+
full_run_command += test
98+
elif '"' not in test:
99+
full_run_command += '"%s"' % test
100+
else:
101+
full_run_command += test.replace(" ", "\\ ")
97102

98103
if "(--edge)" in browser_string:
99104
full_run_command += " --edge"

seleniumbase/console_scripts/sb_print.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ def main():
9191
code_lang = "java"
9292
elif file_to_print.lower().endswith(".feature"):
9393
code_lang = "gherkin"
94+
elif file_to_print.lower().endswith(".txt"):
95+
code_lang = "javascript"
96+
elif file_to_print.lower().endswith(".yml"):
97+
code_lang = "javascript"
9498
elif file_to_print.lower().endswith(".in"):
9599
code_lang = "javascript"
96100
elif "." not in file_to_print:

seleniumbase/core/log_helper.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,9 @@ def log_test_failure_data(test, test_logpath, driver, browser, url=None):
190190
except Exception:
191191
exc_message = "(Unknown Exception)"
192192
traceback_message = "(Unknown Traceback)"
193-
data_to_save.append("Traceback: " + traceback_message)
194-
data_to_save.append("Exception: " + str(exc_message))
193+
traceback_message = str(traceback_message).strip()
194+
data_to_save.append("Traceback:\n %s" % traceback_message)
195+
data_to_save.append("Exception: %s" % exc_message)
195196
else:
196197
traceback_message = None
197198
if hasattr(test, "is_behave") and test.is_behave:
@@ -232,16 +233,16 @@ def log_test_failure_data(test, test_logpath, driver, browser, url=None):
232233
if "/site-packages/pluggy/" not in stack:
233234
if "/site-packages/_pytest/" not in stack:
234235
good_stack.append(stack)
235-
traceback_message = "".join(good_stack)
236-
data_to_save.append("Traceback: " + traceback_message)
236+
traceback_message = str("".join(good_stack)).strip()
237+
data_to_save.append("Traceback:\n %s" % traceback_message)
237238
if hasattr(sys, "last_value"):
238239
last_value = sys.last_value
239240
if last_value:
240-
data_to_save.append("Exception: %s" + str(last_value))
241+
data_to_save.append("Exception: %s" % last_value)
241242
elif hasattr(sb_config, "_excinfo_value"):
242243
data_to_save.append("Exception: %s" % sb_config._excinfo_value)
243244
else:
244-
data_to_save.append("Traceback: " + traceback_message)
245+
data_to_save.append("Traceback:\n %s" % traceback_message)
245246
if hasattr(test, "is_nosetest") and test.is_nosetest:
246247
# Also save the data for the report
247248
sb_config._report_test_id = test_id
@@ -395,7 +396,11 @@ def get_test_id(test):
395396

396397
def get_test_name(test):
397398
if "PYTEST_CURRENT_TEST" in os.environ:
398-
test_name = os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
399+
full_name = os.environ["PYTEST_CURRENT_TEST"]
400+
if "] " in full_name:
401+
test_name = full_name.split("] ")[0] + "]"
402+
else:
403+
test_name = full_name.split(" ")[0]
399404
elif test.is_pytest:
400405
test_name = "%s.py::%s::%s" % (
401406
test.__class__.__module__.split(".")[-1],
@@ -410,16 +415,6 @@ def get_test_name(test):
410415
)
411416
if test._sb_test_identifier and len(str(test._sb_test_identifier)) > 6:
412417
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
423418
return test_name
424419

425420

seleniumbase/fixtures/base_case.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ def open(self, url):
251251
or "ERR_CONNECTION_CLOSED" in e.msg
252252
or "ERR_CONNECTION_RESET" in e.msg
253253
or "ERR_NAME_NOT_RESOLVED" in e.msg
254+
or "ERR_INTERNET_DISCONNECTED" in e.msg
254255
):
255256
shared_utils.check_if_time_limit_exceeded()
256257
self.__check_browser()
@@ -14048,17 +14049,21 @@ def __get_test_id(self):
1404814049
if self._sb_test_identifier and len(str(self._sb_test_identifier)) > 6:
1404914050
test_id = self._sb_test_identifier
1405014051
test_id = test_id.replace(".py::", ".").replace("::", ".")
14051-
test_id = test_id.replace("/", ".")
14052+
test_id = test_id.replace("/", ".").replace(" ", "_")
1405214053
elif hasattr(self, "_using_sb_fixture") and self._using_sb_fixture:
1405314054
test_id = sb_config._latest_display_id
1405414055
test_id = test_id.replace(".py::", ".").replace("::", ".")
14055-
test_id = test_id.replace("/", ".")
14056+
test_id = test_id.replace("/", ".").replace(" ", "_")
1405614057
return test_id
1405714058

1405814059
def __get_test_id_2(self):
1405914060
"""The id for SeleniumBase Dashboard entries."""
1406014061
if "PYTEST_CURRENT_TEST" in os.environ:
14061-
return os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
14062+
full_name = os.environ["PYTEST_CURRENT_TEST"]
14063+
if "] " in full_name:
14064+
return full_name.split("] ")[0] + "]"
14065+
else:
14066+
return full_name.split(" ")[0]
1406214067
if hasattr(self, "is_behave") and self.is_behave:
1406314068
return self.__get_test_id()
1406414069
test_id = "%s.%s.%s" % (
@@ -14075,7 +14080,11 @@ def __get_test_id_2(self):
1407514080
def __get_display_id(self):
1407614081
"""The id for running a test from pytest. (Displayed on Dashboard)"""
1407714082
if "PYTEST_CURRENT_TEST" in os.environ:
14078-
return os.environ["PYTEST_CURRENT_TEST"].split(" ")[0]
14083+
full_name = os.environ["PYTEST_CURRENT_TEST"]
14084+
if "] " in full_name:
14085+
return full_name.split("] ")[0] + "]"
14086+
else:
14087+
return full_name.split(" ")[0]
1407914088
if hasattr(self, "is_behave") and self.is_behave:
1408014089
file_name = sb_config.behave_scenario.filename
1408114090
line_num = sb_config.behave_line_num
@@ -14222,6 +14231,7 @@ def __process_dashboard(self, has_exception, init=False):
1422214231
alt_test_id = sb_config._display_id[test_id]
1422314232
alt_test_id = alt_test_id.replace(".py::", ".")
1422414233
alt_test_id = alt_test_id.replace("::", ".")
14234+
alt_test_id = alt_test_id.replace(" ", "_")
1422514235
if alt_test_id in sb_config._results.keys():
1422614236
sb_config._results.pop(alt_test_id)
1422714237
if test_id in sb_config._results.keys() and (

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
'markdown-it-py==2.2.0;python_version>="3.7"', # For new "rich"
221221
'mdurl==0.1.2;python_version>="3.7"', # For new "rich"
222222
'rich==12.6.0;python_version<"3.7"',
223-
'rich==13.3.1;python_version>="3.7"',
223+
'rich==13.3.2;python_version>="3.7"',
224224
],
225225
extras_require={
226226
# pip install -e .[allure]

0 commit comments

Comments
 (0)