Home
Relevant source files
The following files were used as context for generating this wiki page:
- README.md
- pyproject.toml
- src/flext_tests/_models/_filesystem_parts/filesystem_part_01.py
- src/flext_tests/_utilities/_files/_info.py
- src/flext_tests/_utilities/_files/_creation_parts/creation_part_03.py
- src/flext_tests/_validator/_markdown_parts/markdown_part_01.py
- src/flext_tests/_validator/tests.py
flext-tests is the shared test infrastructure for the FLEXT ecosystem, providing a centralized suite of test utilities, builders, factories, and validation logic. It is designed to support Python 3.13+ environments and integrates deeply with Pydantic v2 and Pytest to ensure robust testing standards across the project landscape.
Sources: README.md:9-12, pyproject.toml:28-40
The project serves as a cornerstone for quality assurance within the FLEXT architecture, enforcing strict rules through specialized validators (e.g., Markdown and Python test architecture validation) and providing powerful filesystem management utilities for creating and analyzing temporary test artifacts.
Sources: README.md:32-34, src/flext_tests/_validator/_markdown_parts/markdown_part_01.py:17-25
Core Filesystem Utilities
The filesystem module provides models and mixins for high-fidelity file operations. It includes automated format detection, comprehensive metadata extraction (via FileInfo), and structured file creation.
Filesystem Models
The FileInfo class provides a detailed view of a file's state, including its existence, size, line count, and security hashes.
| Field | Type | Description |
|---|---|---|
exists | bool | True if the file exists on disk. |
path | Path | Absolute path to the file. |
size | int | Size in bytes. |
sha256 | str | Hex-encoded SHA-256 digest. |
content_meta | ContentMeta | Metadata for parsed JSON/YAML/CSV files. |
Sources: src/flext_tests/_models/_filesystem_parts/filesystem_part_01.py:20-63
File Creation Logic
The system supports creating files from various Python objects (strings, bytes, dicts, sequences) with automatic format detection.
The diagram shows the sequence from receiving raw content to returning the final Path object while ensuring cleanup tracking.
Sources: src/flext_tests/_utilities/_files/_creation_parts/creation_part_03.py:20-80
Validation Infrastructure
flext-tests includes specialized validators to enforce architectural boundaries and coding standards.
Markdown Validator
The Markdown validator scans .md files to ensure embedded Python code blocks are syntactically correct and adhere to FLEXT-specific rules, such as requiring from __future__ import annotations and forbidding legacy typing imports.
| Rule ID | Logic | Source |
|---|---|---|
MD-001 | Syntax validation (via compile) | markdown_part_01.py:73-86 |
MD-002 | Forbidden typing imports (e.g., Optional, Union) | markdown_part_01.py:116-141 |
MD-003 | Missing future annotations import | markdown_part_01.py:173-194 |
MD-004 | Forbidden object type annotations | markdown_part_01.py:150-165 |
Sources: src/flext_tests/_validator/_markdown_parts/markdown_part_01.py:70-194
Test Layer Validator
The FlextValidatorTests class detects violations within test files, specifically targeting usage of legacy mocking tools that are discouraged in the FLEXT ecosystem.
This flow illustrates how the test scanner identifies prohibited testing patterns.
Sources: src/flext_tests/_validator/tests.py:153-172
Make Command Registry
The project facilitates the promotion of scripts into the make ecosystem by parsing flext-command headers within Python files.
- Header Parsing: Extracting metadata from TOML-formatted comments at the start of files.
- Alias Management: Handling command aliases and verb mapping.
- Help Rendering: Generating dynamic terminal help based on the registered commands.
Sources: src/flext_tests/_utilities/_make_parts/make_parsing_part_01.py:16-52, src/flext_tests/_utilities/_make_parts/make_rendering_part_02.py:22-45
Summary
flext-tests provides the foundational building blocks for testing in the FLEXT ecosystem. By combining strict architectural validation with high-level filesystem and CLI utilities, it ensures that all projects within the ecosystem maintain a high baseline of quality and consistency.
Sources: README.md:9-12, pyproject.toml:44-58