@@ -15,10 +15,10 @@ def setUp(self):
1515 self .name_diff = os_helper .TESTFN + '-diff'
1616 data = 'Contents of file go here.\n '
1717 for name in [self .name , self .name_same , self .name_diff ]:
18- with open (name , 'w' ) as output :
18+ with open (name , 'w' , encoding = "utf-8" ) as output :
1919 output .write (data )
2020
21- with open (self .name_diff , 'a+' ) as output :
21+ with open (self .name_diff , 'a+' , encoding = "utf-8" ) as output :
2222 output .write ('An extra line.\n ' )
2323 self .dir = tempfile .gettempdir ()
2424
@@ -72,10 +72,10 @@ def setUp(self):
7272 fn = 'FiLe' # Verify case-insensitive comparison
7373 else :
7474 fn = 'file'
75- with open (os .path .join (dir , fn ), 'w' ) as output :
75+ with open (os .path .join (dir , fn ), 'w' , encoding = "utf-8" ) as output :
7676 output .write (data )
7777
78- with open (os .path .join (self .dir_diff , 'file2' ), 'w' ) as output :
78+ with open (os .path .join (self .dir_diff , 'file2' ), 'w' , encoding = "utf-8" ) as output :
7979 output .write ('An extra file.\n ' )
8080
8181 def tearDown (self ):
@@ -103,7 +103,7 @@ def test_cmpfiles(self):
103103 "Comparing directory to same fails" )
104104
105105 # Add different file2
106- with open (os .path .join (self .dir , 'file2' ), 'w' ) as output :
106+ with open (os .path .join (self .dir , 'file2' ), 'w' , encoding = "utf-8" ) as output :
107107 output .write ('Different contents.\n ' )
108108
109109 self .assertFalse (filecmp .cmpfiles (self .dir , self .dir_same ,
@@ -188,7 +188,7 @@ def test_dircmp(self):
188188 self ._assert_report (d .report , expected_report )
189189
190190 # Add different file2
191- with open (os .path .join (self .dir_diff , 'file2' ), 'w' ) as output :
191+ with open (os .path .join (self .dir_diff , 'file2' ), 'w' , encoding = "utf-8" ) as output :
192192 output .write ('Different contents.\n ' )
193193 d = filecmp .dircmp (self .dir , self .dir_diff )
194194 self .assertEqual (d .same_files , ['file' ])
0 commit comments