@@ -409,7 +409,7 @@ def test_implicit_binary_modes(self):
409409 self .assertEqual (file_data , uncompressed * 2 )
410410
411411 def test_text_modes (self ):
412- uncompressed = data1 .decode ("ascii" ) * 50
412+ uncompressed = data1 .decode ("ascii" ). replace ( " \n " , os . linesep ) * 50
413413 with gzip .open (self .filename , "wt" ) as f :
414414 f .write (uncompressed )
415415 with open (self .filename , "rb" ) as f :
@@ -436,7 +436,7 @@ def test_bad_params(self):
436436
437437 def test_encoding (self ):
438438 # Test non-default encoding.
439- uncompressed = data1 .decode ("ascii" ) * 50
439+ uncompressed = data1 .decode ("ascii" ). replace ( " \n " , os . linesep ) * 50
440440 with gzip .open (self .filename , "wt" , encoding = "utf-16" ) as f :
441441 f .write (uncompressed )
442442 with open (self .filename , "rb" ) as f :
@@ -456,7 +456,7 @@ def test_encoding_error_handler(self):
456456 def test_newline (self ):
457457 # Test with explicit newline (universal newline mode disabled).
458458 uncompressed = data1 .decode ("ascii" ) * 50
459- with gzip .open (self .filename , "wt" ) as f :
459+ with gzip .open (self .filename , "wt" , newline = " \n " ) as f :
460460 f .write (uncompressed )
461461 with gzip .open (self .filename , "rt" , newline = "\r " ) as f :
462462 self .assertEqual (f .readlines (), [uncompressed ])
0 commit comments