Skip to content

test(scan): cover UTF-8 decoding of JSONL datasets#2550

Merged
kevinmessiaen merged 4 commits into
Giskard-AI:mainfrom
weijun-xia:test/scan-dataset-utf8
Jun 22, 2026
Merged

test(scan): cover UTF-8 decoding of JSONL datasets#2550
kevinmessiaen merged 4 commits into
Giskard-AI:mainfrom
weijun-xia:test/scan-dataset-utf8

Conversation

@weijun-xia

Copy link
Copy Markdown
Contributor

What

Add a regression test covering UTF-8 decoding of JSONL datasets in DatasetScenarioGenerator.

Why

#2544 changed the dataset loader to read JSONL with encoding="utf-8", but no existing test exercises non-ASCII content: the stubs build their JSON with json.dumps(...) (default ensure_ascii=True), so they only ever contain ASCII and would pass even if the loader fell back to the platform locale encoding.

Change

tests/generators/test_base.py: add test_dataset_generator_reads_utf8_content, which writes a stub with non-ASCII scenario names (Latin-accented, CJK, Cyrillic) using encoding="utf-8" and asserts they round-trip through the generator. This locks in the UTF-8 read behaviour independently of the platform locale (on Windows the default open() codec is not UTF-8, so without #2544 this test would fail).

Verification

  • pytest tests/generators/test_base.py -> 7 passed
  • ruff check tests/generators/test_base.py -> clean

The dataset generator reads JSONL as UTF-8 (introduced in Giskard-AI#2544), but no
test exercised non-ASCII content: the existing stubs use json.dumps with
the default ensure_ascii=True, so they only ever contain ASCII.

Add a regression test that writes a stub with non-ASCII scenario names
(Latin-accented, CJK and Cyrillic) as UTF-8 and asserts they round-trip,
locking in the UTF-8 read behaviour independently of the platform locale.

Signed-off-by: xiaweiwei67-stack <xiaweiwei67@gmail.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new asynchronous test, 'test_dataset_generator_reads_utf8_content', to verify that non-ASCII scenario content is correctly decoded as UTF-8 regardless of the system locale. There are no review comments, and I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@kevinmessiaen kevinmessiaen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the test is a good addition but I'd move the import at top of the file

Comment thread libs/giskard-scan/tests/generators/test_base.py Outdated
kevinmessiaen and others added 2 commits June 19, 2026 09:49
Move json and base_mod imports out of the individual test functions to
the module top, removing the per-test inline duplicates.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@weijun-xia

Copy link
Copy Markdown
Contributor Author

Thanks for the review! I moved the imports to the top of the file, and hoisted the existing in-function imports there too for consistency.

@weijun-xia

Copy link
Copy Markdown
Contributor Author

Thanks for applying the import hoist and merging main directly -- my local push raced with yours, so I've dropped my duplicate commit. Looks good on my end; happy to make any further tweaks if needed.

@kevinmessiaen
kevinmessiaen merged commit 5462c4a into Giskard-AI:main Jun 22, 2026
49 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants