Skip to content

Commit 920597e

Browse files
committed
Add extra reliability for multi-threaded test runs
1 parent a1e6686 commit 920597e

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

seleniumbase/core/download_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ def reset_downloads_folder():
3535

3636
def reset_downloads_folder_assistant(archived_downloads_folder):
3737
if not os.path.exists(archived_downloads_folder):
38-
os.makedirs(archived_downloads_folder)
38+
try:
39+
os.makedirs(archived_downloads_folder)
40+
except Exception:
41+
pass # Should only be reachable during multi-threaded test runs
3942
new_archived_downloads_sub_folder = "%s/downloads_%s" % (
4043
archived_downloads_folder, int(time.time()))
4144
if os.path.exists(downloads_path):

seleniumbase/core/report_helper.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def clear_out_old_report_logs(archive_past_runs=True, get_log_folder=False):
6666
abs_path = os.path.abspath('.')
6767
file_path = abs_path + "/%s" % LATEST_REPORT_DIR
6868
if not os.path.exists(file_path):
69-
os.makedirs(file_path)
69+
try:
70+
os.makedirs(file_path)
71+
except Exception:
72+
pass # Should only be reachable during multi-threaded runs
7073

7174
if archive_past_runs:
7275
archive_timestamp = int(time.time())

seleniumbase/fixtures/base_case.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3025,12 +3025,19 @@ def tearDown(self):
30253025
self.save_screenshot_after_test):
30263026
test_logpath = self.log_path + "/" + test_id
30273027
if not os.path.exists(test_logpath):
3028-
os.makedirs(test_logpath)
3028+
try:
3029+
os.makedirs(test_logpath)
3030+
except Exception:
3031+
pass # Only reachable during multi-threaded runs
30293032
log_helper.log_screenshot(test_logpath, self.driver)
3033+
self.__add_pytest_html_extra()
30303034
if self.with_testing_base and has_exception:
30313035
test_logpath = self.log_path + "/" + test_id
30323036
if not os.path.exists(test_logpath):
3033-
os.makedirs(test_logpath)
3037+
try:
3038+
os.makedirs(test_logpath)
3039+
except Exception:
3040+
pass # Only reachable during multi-threaded runs
30343041
if ((not self.with_screen_shots) and (
30353042
not self.with_basic_test_info) and (
30363043
not self.with_page_source)):
@@ -3096,7 +3103,10 @@ def tearDown(self):
30963103
self._testMethodName)
30973104
test_logpath = "latest_logs/" + test_id
30983105
if not os.path.exists(test_logpath):
3099-
os.makedirs(test_logpath)
3106+
try:
3107+
os.makedirs(test_logpath)
3108+
except Exception:
3109+
pass # Only reachable during multi-threaded runs
31003110
log_helper.log_test_failure_data(
31013111
self, test_logpath, self.driver, self.browser)
31023112
if len(self._drivers_list) > 0:
@@ -3108,7 +3118,10 @@ def tearDown(self):
31083118
self._testMethodName)
31093119
test_logpath = "latest_logs/" + test_id
31103120
if not os.path.exists(test_logpath):
3111-
os.makedirs(test_logpath)
3121+
try:
3122+
os.makedirs(test_logpath)
3123+
except Exception:
3124+
pass # Only reachable during multi-threaded runs
31123125
log_helper.log_screenshot(test_logpath, self.driver)
31133126
# Finally close all open browser windows
31143127
self.__quit_all_drivers()

0 commit comments

Comments
 (0)