aarmens702-hub commented on code in PR #76699:
URL: https://github.com/apache/airflow/pull/76699#discussion_r4714577813
##########
providers/common/ai/tests/unit/common/ai/utils/test_file_analysis.py:
##########
@@ -425,6 +425,38 @@ def test_csv_values_keep_their_quotes(self, tmp_path,
csv_value, expected_row):
assert f"Header: name, note\nSample rows:\nSmith, {expected_row}" in
request.user_content
+ @pytest.mark.parametrize(
+ ("filename", "content", "expected"),
+ [
+ pytest.param("people.csv", "name,city\nSmith,Oslo\n", "Header:
name, city\n", id="csv"),
+ pytest.param("people.json", '[{"name": "Smith"}]', '[\n {\n
"name": "Smith"', id="json"),
+ pytest.param("notes.txt", "first line", "\nfirst line", id="txt"),
+ ],
+ )
+ @pytest.mark.parametrize("encoding", ["utf-8-sig", "utf-16"])
+ def test_byte_order_mark_is_not_part_of_the_content(
+ self, tmp_path, filename, content, expected, encoding
+ ):
+ # Excel's "CSV UTF-8" and Windows PowerShell's UTF-8 files start with
a byte order mark.
+ # Windows PowerShell 5.1 ``>`` and ``Out-File`` write UTF-16LE with a
byte order mark.
+ path = tmp_path / filename
+ path.write_text(content, encoding=encoding)
Review Comment:
Good catch, thanks. The test now writes each byte order mark explicitly with
`write_bytes`: UTF-8 (`EF BB BF`), UTF-16LE (`FF FE`) and UTF-16BE (`FE FF` +
`content.encode("utf-16-be")`). So both UTF-16 branches run whatever the host
byte order. I checked that dropping `b"\xfe\xff"` from the tuple now fails the
three big-endian cases.
Drafted-by: Claude Code (Opus 5.5); reviewed by @aarmens702-hub before
posting
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]