@@ -148,16 +148,16 @@ def file_replace(file_name: Path, old_text: str, new_text: str) -> Iterator[None
148148 """
149149 file_text = ""
150150 if old_text :
151- file_text = file_name .read_text ()
151+ file_text = file_name .read_text (encoding = "utf-8" )
152152 if old_text not in file_text :
153153 raise Exception ("Old text {old_text!r} not found in {file_name}" )
154154 updated_text = file_text .replace (old_text , new_text )
155- file_name .write_text (updated_text )
155+ file_name .write_text (updated_text , encoding = "utf-8" )
156156 try :
157157 yield
158158 finally :
159159 if old_text :
160- file_name .write_text (file_text )
160+ file_name .write_text (file_text , encoding = "utf-8" )
161161
162162
163163def file_must_exist (file_name : str , kind : str = "file" ) -> Path :
@@ -624,7 +624,7 @@ def run_no_coverage(self, env: Env) -> float:
624624 def run_with_coverage (self , env : Env , cov_ver : Coverage ) -> float :
625625 env .shell .run_command (f"{ env .python } -m pip install { cov_ver .pip_args } " )
626626 pforce = Path ("force.ini" )
627- pforce .write_text ("[run]\n branch=false\n " )
627+ pforce .write_text ("[run]\n branch=false\n " , encoding = "utf-8" )
628628 with env .shell .set_env ({"COVERAGE_FORCE_CONFIG" : str (pforce .resolve ())}):
629629 env .shell .run_command (f"{ env .python } -m pytest { self .FAST } --cov" )
630630 duration = env .shell .last_duration
@@ -907,13 +907,13 @@ def __init__(
907907
908908 def save_results (self ) -> None :
909909 """Save current results to the JSON file."""
910- with self .results_file .open ("w" ) as f :
910+ with self .results_file .open ("w" , encoding = "utf-8" ) as f :
911911 json .dump ({" " .join (k ): v for k , v in self .result_data .items ()}, f )
912912
913913 def load_results (self ) -> dict [ResultKey , list [float ]]:
914914 """Load results from the JSON file if it exists."""
915915 if self .results_file .exists ():
916- with self .results_file .open ("r" ) as f :
916+ with self .results_file .open ("r" , encoding = "utf-8" ) as f :
917917 data : dict [str , list [float ]] = json .load (f )
918918 return {
919919 (k .split ()[0 ], k .split ()[1 ], k .split ()[2 ]): v for k , v in data .items ()
0 commit comments