Skip to content

test: add unit tests for the unflatten utility#5651

Closed
eeshsaxena wants to merge 1 commit into
bentoml:mainfrom
eeshsaxena:test-unflatten-utility
Closed

test: add unit tests for the unflatten utility#5651
eeshsaxena wants to merge 1 commit into
bentoml:mainfrom
eeshsaxena:test-unflatten-utility

Conversation

@eeshsaxena

Copy link
Copy Markdown

What does this PR do?

Adds a unit test suite for bentoml/_internal/utils/unflatten.py, which previously had no test coverage anywhere in the suite.

unflatten turns flat dotted/bracketed keys into nested structures, and it has quite a few branches worth pinning down. The new tests/unit/_internal/utils/test_unflatten.py covers:

  • Nested dicts ({"foo.bar": "val"}{"foo": {"bar": "val"}})
  • Nested lists, lists of lists, and lists of dicts
  • Empty input, plain terminals, deep nesting, and preserved empty-string values
  • Accepting an iterable of (key, value) pairs, not just a dict
  • Quoted keys keeping a literal dot
  • Error paths: conflicting container/terminal types (both directions), missing list indices, and non-string keys

Tests only; no library code changed. Runs green locally (17 passed) and ruff check / ruff format --check are clean on the file.

Before submitting:

Adds coverage for _internal/utils/unflatten.py, which was previously
untested. Covers nested dicts, lists, lists of lists, lists of dicts,
sequence-of-pairs input, quoted keys, and the error paths (conflicting
container/terminal types, missing list indices, and non-string keys).

Signed-off-by: eeshsaxena <eeshsaxena@gmail.com>
@eeshsaxena
eeshsaxena requested a review from a team as a code owner July 4, 2026 02:52
@eeshsaxena
eeshsaxena requested review from bojiang and removed request for a team July 4, 2026 02:52
@eeshsaxena eeshsaxena closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant