@@ -732,7 +732,13 @@ async def test_crawler_push_and_export_data(tmp_path: Path) -> None:
732732 {'id' : 1 , 'test' : 'test' },
733733 {'id' : 2 , 'test' : 'test' },
734734 ]
735- assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\r \n 0,test\r \n 1,test\r \n 2,test\r \n '
735+
736+ # On Windows, text mode file writes convert \n to \r\n, resulting in \r\n line endings.
737+ # On Unix/Linux, \n remains as \n.
738+ if sys .platform == 'win32' :
739+ assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\r \n 0,test\r \n 1,test\r \n 2,test\r \n '
740+ else :
741+ assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\n 0,test\n 1,test\n 2,test\n '
736742
737743
738744async def test_crawler_export_data_additional_kwargs (tmp_path : Path ) -> None :
@@ -770,7 +776,12 @@ async def handler(context: BasicCrawlingContext) -> None:
770776 {'id' : 2 , 'test' : 'test' },
771777 ]
772778
773- assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\r \n 0,test\r \n 1,test\r \n 2,test\r \n '
779+ # On Windows, text mode file writes convert \n to \r\n, resulting in \r\n line endings.
780+ # On Unix/Linux, \n remains as \n.
781+ if sys .platform == 'win32' :
782+ assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\r \n 0,test\r \n 1,test\r \n 2,test\r \n '
783+ else :
784+ assert (tmp_path / 'dataset.csv' ).read_bytes () == b'id,test\n 0,test\n 1,test\n 2,test\n '
774785
775786
776787async def test_context_update_kv_store () -> None :
0 commit comments