Getting Started & Integration
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
The flext-tests infrastructure provides shared test utilities, builders, factories, and validation logic for the FLEXT ecosystem. Its primary purpose is to offer a standardized test infrastructure that enforces architectural rules through specialized validators and simplifies filesystem-related test operations.
Integration with the FLEXT ecosystem is achieved through a set of public surfaces and automated quality gates. The project utilizes a parent MRO (Method Resolution Order) chain defined by dependencies in pyproject.toml and exposes public extensions through a facade-based architecture.
Sources: README.md:1-12, pyproject.toml:23-42
Project Setup and Dependencies
Integration begins with configuring the Python environment. flext-tests requires Python 3.13 and leverages several core testing libraries including pytest, hypothesis, factory-boy, and faker.
Core Dependencies
| Dependency | Purpose |
|---|---|
pytest | Primary testing framework and runner. |
hypothesis | Property-based testing support. |
factory-boy | Object factory generation for tests. |
flext-core | Core FLEXT primitives and utilities. |
flext-infra | Infrastructure and model management. |
Sources: pyproject.toml:23-42, pyproject.toml:200-205
Pytest Plugin Integration
The library registers itself as a pytest plugin, providing automatic access to fixtures and enforcement rules during test execution.
[project.entry-points.pytest11]
flext_tests = "flext_tests.conftest_plugin"
flext_tests_enforcement = "flext_tests._fixtures.enforcement"
Sources: pyproject.toml:59-61
Filesystem Test Integration
One of the primary integration points is the filesystem utility layer (tf), which provides models and mixins for creating and inspecting temporary test files with automatic format detection.
File Creation Flow
The following diagram illustrates the process of creating a test file using the FlextTestsFilesCreationMixin.
The create method supports various content types (strings, bytes, models, or mappings) and handles the serialization based on the detected or specified format (JSON, YAML, CSV, Binary, or Text).
Sources: src/flext_tests/_utilities/_files/_creation_parts/creation_part_03.py:22-86, src/flext_tests/_models/_filesystem_parts/filesystem_part_01.py:64-118
Filesystem Models
The system uses structured models to return comprehensive information about files generated or analyzed during tests.
| Field | Type | Description |
|---|---|---|
exists | bool | True if the file exists on disk. |
path | Path | None | Absolute path to the file. |
size | int | File size in bytes. |
fmt | str | Detected format label (e.g., "json", "csv"). |
content_meta | ContentMeta | Metadata for parsed files (key counts, row counts). |
Sources: src/flext_tests/_models/_filesystem_parts/filesystem_part_01.py:19-62
Architectural Validation
flext-tests integrates enforcement rules directly into the development workflow via specialized validators. These ensure that code and documentation adhere to FLEXT standards.
Validation Sequence
The validation process typically follows this flow when scanning files:
Validator Types
- Markdown Validator: Scans
.mdfiles to ensure Python code blocks are syntactically correct and follow typing standards (e.g., forbiddingfrom typing import Anyin favor of contracts). - Tests Validator: Detects forbidden testing patterns such as direct use of
unittest.mockormonkeypatch, enforcing the use of FLEXT-approved abstractions.
Sources: src/flext_tests/_validator/_markdown_parts/markdown_part_01.py:23-50, src/flext_tests/_validator/tests.py:173-200
Quality Gates
Integration is enforced through "Quality Gates" defined in the project's AGENTS.md and executed via make verbs.
make check: Runs static analysis and linting.make test: Executes the test suite usingpytest.make val: Runs the architectural validators mentioned above.make docs: Generates technical documentation.
Sources: README.md:38-40
Summary
Integrating flext-tests involves configuring the pyproject.toml to include the necessary dependencies and plugins, utilizing the filesystem mixins for robust test data setup, and adhering to the architectural rules enforced by the validation layer. This ensures that tests within the FLEXT ecosystem remain consistent, maintainable, and aligned with the project's engineering standards.