kaxil commented on code in PR #76699:
URL: https://github.com/apache/airflow/pull/76699#discussion_r4701981241
##########
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:
`encoding="utf-16"` writes in the host's byte order, so on CI every case
here starts with `FF FE` and the `b"\xfe\xff"` branch never runs. Dropping it
from the tuple keeps all six cases green, while a big-endian JSON file then
fails to parse. Could you add a case that writes `b"\xfe\xff" +
content.encode("utf-16-be")` with `write_bytes`?
--
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]