fix: add rule to prevent test files from having the same name#9671
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
01c5b90 to
c76f88b
Compare
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Architecture diagram
sequenceDiagram
participant Dev as Developer
participant Git as Git Hook (pre-commit)
participant Script as check_test_filenames.py
participant Fs as tests/ Directory
participant Ignore as Ignored Paths
Note over Dev,Ignore: Pre-commit Hook Flow
Dev->>Git: git commit
Git->>Script: python scripts/check_test_filenames.py
Script->>Fs: Walk tests/ for test_*.py files
Fs-->>Script: List of file paths
Script->>Script: Check if path is ignored
alt Path in IGNORED_PREFIXES
Script->>Ignore: Skip path
end
Script->>Script: Group by filename (e.g., test_variables.py)
Script->>Script: Check for duplicate basenames
alt Duplicate basenames found
Script-->>Git: Non-zero exit (1)
Git-->>Dev: Reject commit, print duplicate names
else No duplicates
Script-->>Git: Zero exit (0)
Git-->>Dev: Allow commit to proceed
end
Note over Dev,Ignore: Pytest Collection Context
Dev->>Fs: Run pytest
Fs->>Fs: Collect test files
alt Duplicate basenames exist (blocked by hook)
Fs->>Fs: Import clobbering occurs
Fs-->>Dev: Import file mismatch error
else Unique basenames (enforced by hook)
Fs-->>Dev: Successful test collection
end
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a recurring pytest collection flake caused by duplicate test module basenames (pytest’s default import mode imports test files as top-level modules). It introduces a pre-commit check to enforce unique test filenames and adds/relocates several tests under new, non-colliding filenames.
Changes:
- Added a repository script to detect duplicate test basenames under
tests/and fail fast. - Wired the duplicate-filename check into pre-commit via a local hook.
- Added/relocated multiple test modules (session/notebook, session/managers, code_mode) under unique basenames.
Reviewed changes
Copilot reviewed 2 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/_session/notebook/test_filesystem_storage.py | Adds FilesystemStorage coverage; includes a couple tests intending to validate string-path handling. |
| tests/_session/notebook/test_app_file_manager.py | Adds tests for load_notebook / new_notebook helpers and path resolution behavior. |
| tests/_session/managers/test_app_host_kernel_manager.py | Adds unit tests for AppHost kernel/queue manager adapters. |
| tests/_code_mode/test_code_mode_context.py | Adds/relocates comprehensive tests for AsyncCodeModeContext transaction behavior. |
| scripts/check_test_filenames.py | New enforcement script to prevent duplicate test basenames (core of the flake fix). |
| .pre-commit-config.yaml | Adds a local pre-commit hook to run the new test-filename check. |
akshayka
approved these changes
May 22, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.9-dev2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Summary
A common flaky failure pattern is:
Which occurs because we have test files named the same thing (e.g. test_variables.py here).
This PR moves some of these existing files, and adds a pre commit rule to stop users duplicating additional tests.