@@ -693,9 +693,9 @@ def test_save_genome_fitness(self):
693693 try :
694694 self .stats .save_genome_fitness (filename = temp_path )
695695
696- # Read and verify
697- with open (temp_path , 'r' ) as f :
698- lines = f . readlines ()
696+ # Read and verify - use universal newlines to handle Windows/Unix differences
697+ with open (temp_path , 'r' , newline = '' ) as f :
698+ lines = [ line for line in f if line . strip ()] # Filter out empty lines
699699
700700 self .assertEqual (len (lines ), 3 )
701701 # Each line should have best and average fitness
@@ -725,9 +725,9 @@ def test_save_species_count(self):
725725 try :
726726 self .stats .save_species_count (filename = temp_path )
727727
728- # Read and verify
729- with open (temp_path , 'r' ) as f :
730- lines = f . readlines ()
728+ # Read and verify - use universal newlines to handle Windows/Unix differences
729+ with open (temp_path , 'r' , newline = '' ) as f :
730+ lines = [ line for line in f if line . strip ()] # Filter out empty lines
731731
732732 self .assertEqual (len (lines ), 1 ) # 1 generation
733733 # Should have counts for both species
@@ -754,9 +754,9 @@ def test_save_species_fitness(self):
754754 try :
755755 self .stats .save_species_fitness (filename = temp_path )
756756
757- # Read and verify
758- with open (temp_path , 'r' ) as f :
759- lines = f . readlines ()
757+ # Read and verify - use universal newlines to handle Windows/Unix differences
758+ with open (temp_path , 'r' , newline = '' ) as f :
759+ lines = [ line for line in f if line . strip ()] # Filter out empty lines
760760
761761 self .assertEqual (len (lines ), 1 )
762762 # Should contain average fitness (5.0 + 7.0) / 2 = 6.0
0 commit comments