Skip to content

Commit 0038e56

Browse files
committed
Prevent deprecation warnings on Python 3.14
1 parent e48940f commit 0038e56

File tree

25 files changed

+76
-103
lines changed

25 files changed

+76
-103
lines changed

mkdocs_build/prepare.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
""" For preparing the mkdocs-generated seleniumbase.io website. """
22

3-
import codecs
43
import os
54
import re
65
from pathlib import Path
@@ -196,6 +195,6 @@ def main(*args, **kwargs):
196195
)
197196
seleniumbase_lines.append(line)
198197
if changed:
199-
out_file = codecs.open(readme_file, "w+", encoding="utf-8")
198+
out_file = open(readme_file, "w+", encoding="utf-8")
200199
out_file.writelines("\r\n".join(seleniumbase_lines))
201200
out_file.close()

seleniumbase/behave/behave_sb.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,6 @@ def dashboard_pre_processing():
12051205

12061206

12071207
def _create_dashboard_assets_():
1208-
import codecs
12091208
from seleniumbase.js_code.live_js import live_js
12101209
from seleniumbase.core.style_sheet import get_pytest_style
12111210

@@ -1222,7 +1221,7 @@ def _create_dashboard_assets_():
12221221
if existing_pytest_style == get_pytest_style():
12231222
add_pytest_style_css = False
12241223
if add_pytest_style_css:
1225-
out_file = codecs.open(pytest_style_css, "w+", encoding="utf-8")
1224+
out_file = open(pytest_style_css, "w+", encoding="utf-8")
12261225
out_file.writelines(get_pytest_style())
12271226
out_file.close()
12281227
live_js_file = os.path.join(assets_folder, "live.js")
@@ -1234,7 +1233,7 @@ def _create_dashboard_assets_():
12341233
if existing_live_js == live_js:
12351234
add_live_js_file = False
12361235
if add_live_js_file:
1237-
out_file = codecs.open(live_js_file, "w+", encoding="utf-8")
1236+
out_file = open(live_js_file, "w+", encoding="utf-8")
12381237
out_file.writelines(live_js)
12391238
out_file.close()
12401239

seleniumbase/console_scripts/sb_caseplans.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
Output:
1616
Launches the SeleniumBase Case Plans Generator.
1717
"""
18-
import codecs
1918
import colorama
2019
import os
2120
import subprocess
@@ -135,7 +134,7 @@ def generate_case_plan_boilerplates(
135134
file_name = case_id
136135
file_path = os.path.join(full_folder_path, file_name)
137136
if not os.path.exists(file_path):
138-
out_file = codecs.open(file_path, "w+", "utf-8")
137+
out_file = open(file_path, "w+", "utf-8")
139138
out_file.writelines("\r\n".join(data))
140139
out_file.close()
141140
new_plans += 1
@@ -316,7 +315,7 @@ def view_summary_of_existing_case_plans(root, tests):
316315
full_plan = plan_head
317316

318317
file_path = "case_summary.md"
319-
file = codecs.open(file_path, "w+", "utf-8")
318+
file = open(file_path, "w+", "utf-8")
320319
file.writelines("\r\n".join(full_plan))
321320
file.close()
322321

seleniumbase/console_scripts/sb_mkchart.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
and use a "sky" theme with "slide" transition.
2323
The chart can be used as a basic boilerplate.
2424
"""
25-
import codecs
2625
import colorama
2726
import os
2827
import sys
@@ -254,7 +253,7 @@ def main():
254253
continue
255254
new_data.append(line)
256255
data = new_data
257-
file = codecs.open(file_path, "w+", "utf-8")
256+
file = open(file_path, "w+", "utf-8")
258257
file.writelines("\r\n".join(data))
259258
file.close()
260259
if " " not in file_name:

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
and Python boilerplates for setting up customized
1919
test frameworks.
2020
"""
21-
import codecs
2221
import colorama
2322
import os
2423
import sys
@@ -114,7 +113,7 @@ def main():
114113
data.append(seleniumbase_req)
115114
data.append("")
116115
file_path = "%s/%s" % (dir_name, "requirements.txt")
117-
file = codecs.open(file_path, "w+", "utf-8")
116+
file = open(file_path, "w+", "utf-8")
118117
file.writelines("\r\n".join(data))
119118
file.close()
120119

@@ -152,7 +151,7 @@ def main():
152151
data.append(" production: custom marker")
153152
data.append("")
154153
file_path = "%s/%s" % (dir_name, "pytest.ini")
155-
file = codecs.open(file_path, "w+", "utf-8")
154+
file = open(file_path, "w+", "utf-8")
156155
file.writelines("\r\n".join(data))
157156
file.close()
158157

@@ -169,14 +168,14 @@ def main():
169168
data.append("show_skipped=false")
170169
data.append("show_timings=false")
171170
file_path = "%s/%s" % (dir_name, "setup.cfg")
172-
file = codecs.open(file_path, "w+", "utf-8")
171+
file = open(file_path, "w+", "utf-8")
173172
file.writelines("\r\n".join(data))
174173
file.close()
175174

176175
data = []
177176
data.append("")
178177
file_path = "%s/%s" % (dir_name, "__init__.py")
179-
file = codecs.open(file_path, "w+", "utf-8")
178+
file = open(file_path, "w+", "utf-8")
180179
file.writelines("\r\n".join(data))
181180
file.close()
182181

@@ -312,7 +311,7 @@ def main():
312311
data.append("temp_*/")
313312
data.append("node_modules")
314313
file_path = "%s/%s" % (dir_name, ".gitignore")
315-
file = codecs.open(file_path, "w+", "utf-8")
314+
file = open(file_path, "w+", "utf-8")
316315
file.writelines("\r\n".join(data))
317316
file.close()
318317

@@ -324,7 +323,7 @@ def main():
324323
data.append(" ├── requirements.txt")
325324
data.append(" └── setup.cfg")
326325
file_path = "%s/%s" % (dir_name, "outline.rst")
327-
file = codecs.open(file_path, "w+", "utf-8")
326+
file = open(file_path, "w+", "utf-8")
328327
file.writelines("\r\n".join(data))
329328
file.close()
330329
os.system("sbase print %s -n" % file_path)
@@ -368,7 +367,7 @@ def main():
368367
data.append(' self.assert_element("div#login_button_container")')
369368
data.append("")
370369
file_path = "%s/%s" % (dir_name, "my_first_test.py")
371-
file = codecs.open(file_path, "w+", "utf-8")
370+
file = open(file_path, "w+", "utf-8")
372371
file.writelines("\r\n".join(data))
373372
file.close()
374373

@@ -461,7 +460,7 @@ def main():
461460
data.append(' self.assert_text("SeleniumBase", "h2")')
462461
data.append("")
463462
file_path = "%s/%s" % (dir_name, "test_demo_site.py")
464-
file = codecs.open(file_path, "w+", "utf-8")
463+
file = open(file_path, "w+", "utf-8")
465464
file.writelines("\r\n".join(data))
466465
file.close()
467466

@@ -500,7 +499,7 @@ def main():
500499
data.append(' self.assert_title_contains(title_text)')
501500
data.append("")
502501
file_path = "%s/%s" % (dir_name, "parameterized_test.py")
503-
file = codecs.open(file_path, "w+", "utf-8")
502+
file = open(file_path, "w+", "utf-8")
504503
file.writelines("\r\n".join(data))
505504
file.close()
506505

@@ -510,7 +509,7 @@ def main():
510509
data = []
511510
data.append("")
512511
file_path = "%s/%s" % (dir_name_2, "__init__.py")
513-
file = codecs.open(file_path, "w+", "utf-8")
512+
file = open(file_path, "w+", "utf-8")
514513
file.writelines("\r\n".join(data))
515514
file.close()
516515

@@ -545,7 +544,7 @@ def main():
545544
data.append(" pass")
546545
data.append("")
547546
file_path = "%s/%s" % (dir_name_2, "base_test_case.py")
548-
file = codecs.open(file_path, "w+", "utf-8")
547+
file = open(file_path, "w+", "utf-8")
549548
file.writelines("\r\n".join(data))
550549
file.close()
551550

@@ -554,7 +553,7 @@ def main():
554553
data.append(' html = "html"')
555554
data.append("")
556555
file_path = "%s/%s" % (dir_name_2, "page_objects.py")
557-
file = codecs.open(file_path, "w+", "utf-8")
556+
file = open(file_path, "w+", "utf-8")
558557
file.writelines("\r\n".join(data))
559558
file.close()
560559

@@ -570,7 +569,7 @@ def main():
570569
data.append(" self.assert_element(Page.html)")
571570
data.append("")
572571
file_path = "%s/%s" % (dir_name_2, "boilerplate_test.py")
573-
file = codecs.open(file_path, "w+", "utf-8")
572+
file = open(file_path, "w+", "utf-8")
574573
file.writelines("\r\n".join(data))
575574
file.close()
576575

@@ -594,7 +593,7 @@ def main():
594593
data.append(' DataPage().add_input_text(self, "Goodbye!")')
595594
data.append("")
596595
file_path = "%s/%s" % (dir_name_2, "classic_obj_test.py")
597-
file = codecs.open(file_path, "w+", "utf-8")
596+
file = open(file_path, "w+", "utf-8")
598597
file.writelines("\r\n".join(data))
599598
file.close()
600599

@@ -614,7 +613,7 @@ def main():
614613
data.append(' DataPage().add_input_text(sb, "Goodbye!")')
615614
data.append("")
616615
file_path = "%s/%s" % (dir_name_2, "sb_fixture_test.py")
617-
file = codecs.open(file_path, "w+", "utf-8")
616+
file = open(file_path, "w+", "utf-8")
618617
file.writelines("\r\n".join(data))
619618
file.close()
620619

@@ -624,7 +623,7 @@ def main():
624623
data = []
625624
data.append("")
626625
file_path = "%s/%s" % (dir_name_3, "__init__.py")
627-
file = codecs.open(file_path, "w+", "utf-8")
626+
file = open(file_path, "w+", "utf-8")
628627
file.writelines("\r\n".join(data))
629628
file.close()
630629

@@ -652,7 +651,7 @@ def main():
652651
)
653652
data.append("")
654653
file_path = "%s/%s" % (dir_name_3, "google_test.py")
655-
file = codecs.open(file_path, "w+", "utf-8")
654+
file = open(file_path, "w+", "utf-8")
656655
file.writelines("\r\n".join(data))
657656
file.close()
658657

@@ -670,7 +669,7 @@ def main():
670669
data.append(' search_results = "div#center_col"')
671670
data.append("")
672671
file_path = "%s/%s" % (dir_name_3, "google_objects.py")
673-
file = codecs.open(file_path, "w+", "utf-8")
672+
file = open(file_path, "w+", "utf-8")
674673
file.writelines("\r\n".join(data))
675674
file.close()
676675

@@ -702,7 +701,7 @@ def main():
702701
data.append(' self.assert_element("div#login_button_container")')
703702
data.append("")
704703
file_path = "%s/%s" % (dir_name_3, "swag_labs_test.py")
705-
file = codecs.open(file_path, "w+", "utf-8")
704+
file = open(file_path, "w+", "utf-8")
706705
file.writelines("\r\n".join(data))
707706
file.close()
708707

@@ -729,7 +728,7 @@ def main():
729728
data.append(' sb.assert_element("div#login_button_container")')
730729
data.append("")
731730
file_path = "%s/%s" % (dir_name_3, "sb_swag_test.py")
732-
file = codecs.open(file_path, "w+", "utf-8")
731+
file = open(file_path, "w+", "utf-8")
733732
file.writelines("\r\n".join(data))
734733
file.close()
735734

@@ -756,7 +755,7 @@ def main():
756755
data.append(" ├── sb_swag_test.py")
757756
data.append(" └── swag_labs_test.py")
758757
file_path = "%s/%s" % (dir_name, "outline.rst")
759-
file = codecs.open(file_path, "w+", "utf-8")
758+
file = open(file_path, "w+", "utf-8")
760759
file.writelines("\r\n".join(data))
761760
file.close()
762761
if " " not in file_path:

seleniumbase/console_scripts/sb_mkfile.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
BaseCase format supports Languages or Recorder Mode.
4141
UC Mode automatically uses English with SB() format.
4242
"""
43-
import codecs
4443
import colorama
4544
import os
4645
import sys
@@ -413,7 +412,7 @@ def main():
413412
continue
414413
new_data.append(line)
415414
data = new_data
416-
file = codecs.open(file_path, "w+", "utf-8")
415+
file = open(file_path, "w+", "utf-8")
417416
file.writelines("\r\n".join(data))
418417
file.close()
419418
if " " not in file_name:

seleniumbase/console_scripts/sb_mkpres.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
and use "serif" theme with "slide" transition.
2323
The slides can be used as a basic boilerplate.
2424
"""
25-
import codecs
2625
import colorama
2726
import os
2827
import sys
@@ -273,7 +272,7 @@ def main():
273272
continue
274273
new_data.append(line)
275274
data = new_data
276-
file = codecs.open(file_path, "w+", "utf-8")
275+
file = open(file_path, "w+", "utf-8")
277276
file.writelines("\r\n".join(data))
278277
file.close()
279278
if " " not in file_name:

seleniumbase/console_scripts/sb_mkrec.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
Creates a new SeleniumBase test using the Recorder.
3030
If the filename already exists, an error is raised.
3131
"""
32-
import codecs
3332
import colorama
3433
import shutil
3534
import os
@@ -240,7 +239,7 @@ def main():
240239
d2.append("")
241240
data = d2
242241

243-
file = codecs.open(file_path, "w+", "utf-8")
242+
file = open(file_path, "w+", "utf-8")
244243
file.writelines("\r\n".join(data))
245244
file.close()
246245
success = (

seleniumbase/console_scripts/sb_objectify.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
have been replaced with variable names defined in
99
"page_objects.py", supporting the Page Object Pattern.
1010
"""
11-
import codecs
1211
import os
1312
import re
1413
import sys
@@ -136,7 +135,7 @@ def create_objects_file(selector_list_dict=None):
136135
data.append(' html = "html"')
137136
data.append("")
138137
file_path = PAGE_OBJECTS_FILE
139-
file = codecs.open(file_path, "w+", "utf-8")
138+
file = open(file_path, "w+", "utf-8")
140139
file.writelines("\r\n".join(data))
141140
file.close()
142141
if not selector_list_dict:
@@ -3189,7 +3188,7 @@ def main(shell_command):
31893188
# Create SeleniumBase test file
31903189
base_file_name = seleniumbase_file.split(".py")[0]
31913190
converted_file_name = base_file_name + ".py" # Change end to make a copy
3192-
out_file = codecs.open(converted_file_name, "w+", encoding="utf-8")
3191+
out_file = open(converted_file_name, "w+", encoding="utf-8")
31933192
out_file.writelines(seleniumbase_code)
31943193
out_file.close()
31953194
print('\n>>> ["%s"] was updated!\n' % converted_file_name)

seleniumbase/core/browser_launcher.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,14 +2006,12 @@ def _repair_edgedriver(edge_version):
20062006

20072007

20082008
def _mark_driver_repaired():
2009-
import codecs
2010-
20112009
abs_path = os.path.abspath(".")
20122010
driver_repaired_lock = constants.MultiBrowser.DRIVER_REPAIRED
20132011
file_path = os.path.join(abs_path, driver_repaired_lock)
20142012
if not os.path.exists(DOWNLOADS_FOLDER):
20152013
os.makedirs(DOWNLOADS_FOLDER)
2016-
out_file = codecs.open(file_path, "w+", encoding="utf-8")
2014+
out_file = open(file_path, "w+", encoding="utf-8")
20172015
out_file.writelines("")
20182016
out_file.close()
20192017

0 commit comments

Comments
 (0)