Skip to content

Consolidate test infrastructure helpers#3316

Merged
koxudaxi merged 1 commit into
mainfrom
consolidate-test-infrastructure
Jun 11, 2026
Merged

Consolidate test infrastructure helpers#3316
koxudaxi merged 1 commit into
mainfrom
consolidate-test-infrastructure

Conversation

@koxudaxi

@koxudaxi koxudaxi commented Jun 11, 2026

Copy link
Copy Markdown
Owner

No description provided.

@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 06c06eae-770e-4448-8377-180e15e63443

📥 Commits

Reviewing files that changed from the base of the PR and between fe7dbe1 and 83603dd.

📒 Files selected for processing (6)
  • tests/conftest.py
  • tests/main/_builtin_parity.py
  • tests/main/conftest.py
  • tests/main/xmlschema/test_main_xmlschema.py
  • tests/test_conftest_helpers.py
  • tests/test_main_kr.py
🚧 Files skipped from review as they are similar to previous changes (5)
  • tests/main/_builtin_parity.py
  • tests/main/xmlschema/test_main_xmlschema.py
  • tests/conftest.py
  • tests/test_main_kr.py
  • tests/test_conftest_helpers.py

📝 Walkthrough

Walkthrough

This PR centralizes expected-file inference, adds an env-gated builtin-formatter parity test helper for CLI/API flows, refactors conftest helper APIs (memoized CLI options, replaces a boolean flag), updates XML tests to new parameter names, and expands parity-focused tests.

Changes

Test Infrastructure Refactoring

Layer / File(s) Summary
Expected filename inference utility
tests/conftest.py, tests/test_conftest_helpers.py
_infer_expected_file() centralizes logic to derive snapshot filenames by stripping test-function prefixes and appending .py. Replaces inline duplication in create_assert_file_content() and tests.
Built-in formatter parity infrastructure
tests/main/_builtin_parity.py
New module implements conditional parity validation of the built-in formatter against black/isort for CLI and API flows. Includes mock state preservation, content normalization, output comparison, and environment-gated execution.
Conftest integration and API updates
tests/main/conftest.py
Imports new utilities, memoizes CLI option discovery, centralizes filename inference, and replaces boolean assert_output_path_not_exists with explicit file_should_not_exist: Path | None parameter in run_main_and_assert().
XML schema test updates
tests/main/xmlschema/test_main_xmlschema.py
Six error-path tests updated to use new output_should_not_exist parameter instead of deprecated assert_output_path_not_exists.
Comprehensive parity test coverage
tests/test_conftest_helpers.py
Adds tests for mock preservation, formatter detection, output cleanup, comparison logic, and end-to-end parity validation for CLI (file and stdin paths) and API flows with warning preservation.
Test fixture import consolidation
tests/test_main_kr.py
Consolidates local constants (DATA_PATH, TIMESTAMP, etc.) and imports by sourcing them from refactored tests/main/conftest.py, reducing duplication.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • koxudaxi/datamodel-code-generator#3047: Both PRs refactor expected-file inference in tests/main/conftest.py for run_generate_file_and_assert()—main PR centralizes via _infer_expected_file() utility while the retrieved PR uses inline inference.

Poem

🐰 In burrows of test code I hop with a cheer,
I tidy filenames and chase parity near,
I nudge conftest and helpers to tidy their trail,
Then nibble a carrot and wag my soft tail. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Consolidate test infrastructure helpers' accurately reflects the main objective of the PR, which involves refactoring and consolidating test helper utilities across multiple test modules.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch consolidate-test-infrastructure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread tests/main/_builtin_parity.py Fixed
Comment thread tests/main/conftest.py Fixed
@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 11 untouched benchmarks
⏩ 98 skipped benchmarks1


Comparing consolidate-test-infrastructure (83603dd) with main (425b974)

Open in CodSpeed

Footnotes

  1. 98 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@github-actions

github-actions Bot commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

📚 Docs Preview: https://pr-3316.datamodel-code-generator.pages.dev

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (425b974) to head (83603dd).

Additional details and impacted files
@@            Coverage Diff             @@
##              main     #3316    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          117       118     +1     
  Lines        27072     27207   +135     
  Branches      3386      3383     -3     
==========================================
+ Hits         27072     27207   +135     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@koxudaxi koxudaxi force-pushed the consolidate-test-infrastructure branch from fe7dbe1 to 83603dd Compare June 11, 2026 01:46
@koxudaxi koxudaxi merged commit 2fa2097 into main Jun 11, 2026
50 checks passed
@koxudaxi koxudaxi deleted the consolidate-test-infrastructure branch June 11, 2026 03:13
@github-actions

Copy link
Copy Markdown
Contributor

Breaking Change Analysis

Result: No breaking changes detected

Reasoning: The prepared diff, analysis-context, and deleted-lines files reside in /home/runner/work/_temp/release-draft-pr/, outside this session's only allowed working directory. Every read path was blocked: the Read tool's permission was never granted, Bash file readers (cat/wc/ls/find) are blocked for out-of-working-dir paths, cp/ln/python bridges require approval that is auto-denied, and indirection triggers static-analysis blocks. git is also unusable because the checkout is a single root commit showing the entire repo as additions, so it cannot reconstruct PR #3316's actual delta.

Based on the only accessible signal — the merged commit subject "Consolidate test infrastructure helpers (#3316)" — this PR refactors/consolidates internal test-suite helpers. Test infrastructure is not part of the public API surface: it does not affect generated code output, Jinja2 templates, CLI options, the Python API, default behaviors, supported Python versions, or error handling. None of the six breaking-change categories apply to an internal test-helper consolidation. I note this conclusion is based on the PR's stated scope rather than direct line-level diff inspection, which the sandbox prevented.


This analysis was performed by Claude Code Action

@github-actions

Copy link
Copy Markdown
Contributor

🎉 Released in 0.63.0

This PR is now available in the latest release. See the release notes for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants