Skip to content

test(spec-tools): add unit tests for new fork codemods - #3776

Merged
spencer-tb merged 3 commits into
ethereum:forks/bogotafrom
AhmethanKalenderoglu:test/codemod-unit-tests
Oct 13, 2026
Merged

spencer-tb merged 3 commits into
ethereum:forks/bogotafrom
AhmethanKalenderoglu:test/codemod-unit-tests

Conversation

@AhmethanKalenderoglu

Copy link
Copy Markdown
Contributor

Description

Adds tests/spec_tools/test_codemods.py with unit tests for CommentReplaceCommand, StringReplaceCommand and SetConstantCommand, using LibCST's CodemodTest like the issue suggests. RemoveDocstringCommand already has tests in test_new_fork.py, so I left those where they are.

SetConstantCommand needs FullyQualifiedNameProvider, and CodemodTest doesn't set up a cache for it, so those tests write the module to a temp directory and pass a FullRepoManager through context_override.

While writing these I noticed that SetConstantCommand on a tuple assignment like X, Y = 1, 2 replaces the whole right hand side (X, Y = 3), while X = Y = 1 raises NotImplementedError. No fork defines constants that way right now so I didn't touch it here, but I can send a fix separately.

Related Issues or PRs

Fixes #2196

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <description>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Ran ruff, mypy and codespell on the new file. The full just static needs the optimized group, which doesn't build on my Windows machine.

Cute Animal Picture

Ak Geyik

@spencer-tb

Copy link
Copy Markdown
Contributor

Thanks for the PR! Pushed a small trim of the tests and the tuple unpacking fix, LGTM :D

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.98%. Comparing base (e91a505) to head (f34e02c).
⚠️ Report is 6 commits behind head on forks/bogota.

Additional details and impacted files
@@              Coverage Diff              @@
##           forks/bogota    #3776   +/-   ##
=============================================
  Coverage         94.98%   94.98%           
=============================================
  Files               673      673           
  Lines             40831    40831           
  Branches           3747     3747           
=============================================
  Hits              38785    38785           
  Misses             1429     1429           
  Partials            617      617           
Flag Coverage Δ
unittests 94.98% <ø> (ø)

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.

@spencer-tb
spencer-tb merged commit 2f301f3 into ethereum:forks/bogota Oct 13, 2026
20 checks passed
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.

Write LibCST tests for the new fork tool

2 participants