Skip to content

test: add walk() coverage for tuple, set, and nested container types #20

Description

Summary

walk() recursively sanitizes nested data structures (dicts, lists, strings). The current 14 tests cover dicts, lists, and strings well, but there are no tests for tuples, sets, or mixed nested containers.

What to do

Add a TestWalkContainerTypes class to tests/test_walk.py:

  1. Tuple with hostile stringwalk(("hello", "n\u0430vi")) — document whether tuples are traversed or passed through
  2. Set with hostile stringwalk({"hello", "n\u0430vi"}) — document behavior
  3. Deeply nested mixedwalk({"a": [("b", "\u0430")]}) — dict containing list containing tuple
  4. Frozen containerswalk({"key": frozenset(["n\u0430vi"])})
  5. Original not mutated — verify walk() deep-copies and doesn't modify input for all container types

The goal is to document and test the current behavior, even if some types pass through unsanitized. If you find that tuples/sets should be traversed, note it in the PR for discussion.

Files

  • tests/test_walk.py — add new test class

Hints

  • Read src/navi_sanitize/_pipeline.py for the walk() implementation
  • walk() uses deepcopy — original data is never modified
  • Cyrillic \u0430 (а) is a good test char — it maps to Latin a
  • Run tests with: uv run pytest tests/test_walk.py -v --benchmark-disable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions