Skip to content

Tests: inc-site attribute extension construct path + memoized reference target#1468

Draft
rly wants to merge 1 commit into
devfrom
tests/extended-attrs-construct-and-ref
Draft

Tests: inc-site attribute extension construct path + memoized reference target#1468
rly wants to merge 1 commit into
devfrom
tests/extended-attrs-construct-and-ref

Conversation

@rly
Copy link
Copy Markdown
Contributor

@rly rly commented May 2, 2026

Summary

Closes the test gaps PR #283 flagged but never landed:

  • Construct (read) round-trip for inc-site added attributesTestBuildGroupAddedAttr.test_construct_added_attr and TestBuildDatasetAddedAttrs.test_construct_added_attr build a holder containing an extended Bar / BarData with an inc-site ext_attr, then construct from the resulting builder and assert the attribute round-trips. Required adding @ObjectMapper.constructor_arg('ext_attr') to ExtBarMapper / ExtBarDataMapper so the inner mapper can recover an inc-site attribute that is not in its def-site spec.
  • Reference + memoization positive testTestBuildDatasetAddedAttrsWithRef.test_build_added_attr_with_ref builds a holder where the direct extended bar_data field and a sibling typed reference dataset (BarRefDataset) both point at the same BarData instance, and asserts (a) the BarData builder carries the inc-site ext_attr and (b) the reference dataset's ReferenceBuilder resolves to that same memoized builder. Modern code only had the negative-case TestBuildDatasetOfReferencesUnbuiltTarget.

Also uncomments TestBuildGroupRefinedAttr.test_build_refined_attr_wrong_type (the attribute counterpart of TestBuildDatasetRefinedDtype.test_build_refined_dtype_convert — verifies build silently converts int -> int64 when the inc-site spec refines the dtype). The inline TODO is preserved noting that ideally a DtypeConversionWarning would be emitted, mirroring the dataset case.

The four touched mixin / test setUps were refactored to use tests.unit.helpers.utils.create_test_type_map instead of hand-rolling SpecCatalog / SpecNamespace / NamespaceCatalog / TypeMap.

Notes on design choices

PR #283 used a named-untyped dataset with dtype=RefSpec directly holding a Container value. Modern convert_dtype requires a ReferenceBuilder for that path, so the with-ref test instead uses a typed Data subclass (BarRefDataset) holding object references — the canonical "container of references" pattern (mirrors Baz in test_io_map_data.py).

These tests do not move statement / branch coverage numbers (the underlying code paths are already exercised by other tests). They add behavioral guarantees at the inc-site-extension boundary that PR #283 was worried about.

Test plan

  • pytest tests/unit/build_tests/mapper_tests/test_build.py -> 20 passed
  • pytest tests/ -> 1891 passed, 22 skipped, 1 xfailed

🤖 Generated with Claude Code

…d reference target

Closes the gaps PR #283 (#283) flagged but never landed: round-trip construct
coverage for inc-site added attributes (group + dataset) and a positive test
that inc-site attributes are applied when the same dataset is also reachable
through a typed reference dataset.

Also uncomments TestBuildGroupRefinedAttr.test_build_refined_attr_wrong_type
(the attribute counterpart of TestBuildDatasetRefinedDtype.test_build_refined_dtype_convert)
and refactors the BuildGroupExtAttrsMixin / BuildDatasetExtAttrsMixin /
BuildDatasetShapeMixin / TestBuildDatasetAddedAttrsWithRef setUps to use
create_test_type_map.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.20%. Comparing base (41b7f08) to head (234d1c9).

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1468   +/-   ##
=======================================
  Coverage   93.20%   93.20%           
=======================================
  Files          41       41           
  Lines       10176    10176           
  Branches     2103     2103           
=======================================
  Hits         9485     9485           
  Misses        415      415           
  Partials      276      276           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rly rly mentioned this pull request May 2, 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