Skip to content

Commit 6865795

Browse files
committed
windows tests
1 parent 8326a0a commit 6865795

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/unit/crawlers/_basic/test_basic_crawler.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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\n0,test\r\n1,test\r\n2,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\n0,test\r\n1,test\r\n2,test\r\n'
740+
else:
741+
assert (tmp_path / 'dataset.csv').read_bytes() == b'id,test\n0,test\n1,test\n2,test\n'
736742

737743

738744
async 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\n0,test\r\n1,test\r\n2,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\n0,test\r\n1,test\r\n2,test\r\n'
783+
else:
784+
assert (tmp_path / 'dataset.csv').read_bytes() == b'id,test\n0,test\n1,test\n2,test\n'
774785

775786

776787
async def test_context_update_kv_store() -> None:

0 commit comments

Comments
 (0)