◐ Shell
clean mode source ↗

Clippy rules (test related) by ShaharNaveh · Pull Request #7968 · RustPython/RustPython

Caution

Review failed

Failed to post review comments

📝 Walkthrough

Walkthrough

This PR enables three new clippy restriction lints (cfg_not_test, redundant_test_prefix, tests_outside_test_module) in the workspace configuration, then systematically refactors test functions across the entire codebase to comply. Test functions are renamed by removing the test_ prefix, and scattered tests are reorganized into dedicated #[cfg(test)] mod tests modules.

Changes

Test naming and organization refactoring driven by new clippy lints

Layer / File(s) Summary
Workspace clippy lint configuration
Cargo.toml
Added three new clippy restriction lints: cfg_not_test, redundant_test_prefix, and tests_outside_test_module to enforce test naming and module organization standards.
Common module test refactoring
crates/common/src/cformat.rs, crates/common/src/format.rs, crates/common/src/str.rs
Renamed test functions by removing test_ prefix across formatting and string parsing tests (e.g., test_fill_and_alignfill_and_align, test_parse_keyparse_key).
Compiler-core and compiler test refactoring
crates/compiler-core/src/bytecode.rs, crates/compiler-core/src/varint.rs, crates/compiler/src/lib.rs
Renamed exception-table and varint unit tests in bytecode.rs/varint.rs; reorganized smoke tests in compiler/lib.rs into a dedicated #[cfg(test)] mod tests module with test functions renamed from test_* to compile_*.
SRE engine, stdlib, and doc test refactoring
crates/sre_engine/tests/tests.rs, crates/stdlib/src/_opcode.rs, crates/stdlib/src/ssl/oid.rs, crates/doc/src/lib.rs
Reorganized sre_engine tests into #[cfg(test)] module and renamed regex test functions; renamed stdlib opcode and OID lookup tests by removing test_ prefix; renamed doc database test function.
VM module test refactoring
crates/vm/src/... (many files)
Renamed unit test functions across VM modules by removing test_ prefix; reorganized frozen-module and other scattered tests into #[cfg(test)] mod tests modules while preserving test logic and assertions.
C API & JIT test refactoring
crates/capi/*, crates/jit/tests/*
Renamed C-API and JIT test functions, wrapped JIT test files in #[cfg(test)] mod tests, moved helper macros/imports into test modules, and applied small test fixes (syntax and additional assertions) where needed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • RustPython/RustPython#7916: Both PRs modify crates/vm/src/vm/python_run.rs tests for block-expression cases; this PR renames those tests while #7916 adds related test coverage.
  • RustPython/RustPython#7764: Both PRs modify Cargo.toml workspace Clippy lint configuration to enable additional lint rules.
  • RustPython/RustPython#7755: Both PRs update the workspace Clippy lint block; changes are related at the manifest configuration level.

Suggested reviewers

  • youknowone
  • coolreader18

Poem

🐰 In burrows of code I hop and play,
I chase the prefixes far away.
Tests tidy, modules snug and tight,
Clippy nods — the suite feels right.
A carrot of order, quick and spry, hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Clippy rules (test related)' accurately reflects the main change: enabling new Clippy lints in Cargo.toml and refactoring test functions across multiple files to comply with the new lints.
Docstring Coverage ✅ Passed Docstring coverage is 99.43% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

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.