A tool to automatically map Python source files to their corresponding test files.
Project description
🗺️ autotestmap
Instantly discover the connections between your source code and your tests.
autotestmap is a fast, zero-dependency developer utility that scans your Python project and builds a map of which test files are exercising your source code. It helps you quickly find relevant tests, identify potentially untested code, and understand your project's test coverage structure at a glance.
❓ Why use autotestmap?
In any growing Python project, it can be challenging to answer questions like:
- “If I change this file, which tests do I need to run?”
- “Where are the tests for this specific module?”
- “Does this source file even have any tests?”
autotestmap answers these questions by analyzing your codebase and providing a clear, intuitive map of the relationships.
✨ Key Features
- ✅ Automatic Directory Detection: Intelligently finds common
srcandtestsdirectories when run with no arguments. - 🧠 Smart Mapping: Uses two powerful strategies:
- Direct Naming Conventions (e.g.,
user.py→test_user.py) - Static Import Analysis (detects tests that import the source module)
- Direct Naming Conventions (e.g.,
- 🚀 Flexible Usage Modes: Run it against your whole project or focus on a single file.
- ✨ Clean CLI: Beautiful emoji-coded output.
- 🤖 JSON Output: Use
--jsonfor machine-readable results, ideal for CI/CD. - 🕊️ Zero-Dependency: No external libraries needed.
📦 Installation
Install directly from PyPI:
pip install autotestmap
🚀 How to Use
Autotestmap can be run in three different modes depending on your needs.
🔹 Mode 1: Automatic Discovery (No Arguments), Scans for common source (e.g., src, app) and test (tests) folders in your current directory.
🔍 Mode: Auto-discovery
✅ auth.py
🔗 Direct → test_auth.py
✅ models.py
🔎 Indirect → test_user_logic.py
⚠️ payment.py → No tests found
🔹 Mode 2: Specific File Mapping (One Argument), Find all tests related to a single source file:
🔍 Mode: Single file mapping
✅ models.py
🔎 Indirect → test_user_logic.py
🔹 Mode 3: Directory Specification (Two Arguments), Use this if your project has custom directory names:
autotestmap my_app/ specifications/
🧾 Output Legend
✅ [file] – A source file that has at least one associated test.
🔗 Direct – Test file matches by naming convention (strong link).
🔎 Indirect – Test file imports the source file (weaker link).
⚠️ [file] – No matching test found (requires -v flag in directory mode).
🔧 Advanced Usage
🧪 JSON Output
Use the --json flag to get machine-readable output (works in all modes):
{
"auth.py": {
"direct": ["test_auth.py"],
"indirect": []
},
"models.py": {
"direct": [],
"indirect": ["test_user_logic.py"]
},
"payment.py": {
"direct": [],
"indirect": []
}
}
📣 Verbose Mode
To include all source files, even if no tests were found:
autotestmap -v
🤝 Contributing
Contributions are welcome! Whether it's a bug report, feature request, or a pull request — all contributions help make autotestmap better.
Please feel free to open an issue or submit a PR on GitHub.
📄 License This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autotestmap-1.0.0.tar.gz.
File metadata
- Download URL: autotestmap-1.0.0.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b201f8e28cd34e1a932a11f90ffcbe3fa2e6734c66d0d073e25b7db94929cc5
|
|
| MD5 |
180a35aa00b4a5e6facd98877d5ed7a9
|
|
| BLAKE2b-256 |
a5dd55ab54ee30365bd9a929868aa67744484eb6e34e5f9355bd840359312fdc
|
File details
Details for the file autotestmap-1.0.0-py3-none-any.whl.
File metadata
- Download URL: autotestmap-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a96108945126e19e2cff509f516bc78d58bb97f7ee2c4f96587e47cb7a5a73e
|
|
| MD5 |
de81103cdc599aa3f236bc0de35a1eb0
|
|
| BLAKE2b-256 |
0444bc13bcfac38be628c29fb36b3b5ca4e540152108d5d1e36d82f635161818
|