Skip to content

test: improve assertions in test_union_schema#40

Merged
candleindark merged 2 commits intodandi:mainfrom
candleindark:enh-test-union-schema
Mar 19, 2026
Merged

test: improve assertions in test_union_schema#40
candleindark merged 2 commits intodandi:mainfrom
candleindark:enh-test-union-schema

Conversation

@candleindark
Copy link
Copy Markdown
Member

Summary

  • Adds a test sub-case for nested union types (Union[int, Union[str, Bar1]]),
    verifying that nested unions are flattened correctly.
  • Updates all other sub-cases in test_union_schema to assert the full
    SlotDefinition via == rather than checking individual attributes, making
    assertions more complete and consistent with the new nested-union case.
  • For the tuple-choice sub-case, notes=slot.notes is used in the
    SlotDefinition comparison (instead of unittest.mock.ANY) because
    SlotDefinition.__eq__ serializes fields before comparing, which causes
    ANY to be treated as the literal string '<ANY>'. Note content is still
    verified separately with in_exactly_one_string.

Test plan

  • hatch run test.py3.10:pytest tests/test_gen_linkml.py::TestSlotGenerator::test_union_schema

🤖 Generated with Claude Code

Loading
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