Skip to main content

基于交互模式的现代化测试自动化框架,支持多种测试场景

Project description

DF Test Framework

简单、强大、可扩展的现代化 Python 测试自动化框架

PyPI version Python License


核心特性

  • HTTP 客户端 - 同步/异步,拦截器链,自动重试
  • GraphQL/gRPC 客户端 - 完整协议支持
  • 数据库访问 - SQLAlchemy 2.0,Repository + UnitOfWork 模式
  • 消息队列 - Kafka/RabbitMQ/RocketMQ 统一接口
  • 存储客户端 - LocalFile/S3/阿里云 OSS
  • 可观测性 - OpenTelemetry 追踪 + Prometheus 监控
  • 测试工具 - Fixtures、数据构建器、Mock 工具、Allure 集成

安装

# 基础安装
pip install df-test-framework

# 可选依赖
pip install df-test-framework[ui]           # UI 测试(Playwright)
pip install df-test-framework[mq]           # 消息队列
pip install df-test-framework[observability] # 可观测性
pip install df-test-framework[storage]      # 存储客户端
pip install df-test-framework[all]          # 所有功能

快速开始

脚手架创建项目

df-test init my-test-project
cd my-test-project
cp .env.example .env
pytest -v

手动使用

from df_test_framework import Bootstrap, FrameworkSettings
from pydantic import Field

class DemoSettings(FrameworkSettings):
    api_base_url: str = Field(default="https://api.example.com")

runtime = (
    Bootstrap()
    .with_settings(DemoSettings)
    .build()
    .run()
)

http = runtime.http_client()
response = http.get("/users/1")
assert response.status_code == 200

异步高性能模式

import asyncio
from df_test_framework import AsyncHttpClient

async def test_concurrent():
    async with AsyncHttpClient("https://api.example.com") as client:
        tasks = [client.get(f"/users/{i}") for i in range(100)]
        responses = await asyncio.gather(*tasks)
        assert len(responses) == 100

asyncio.run(test_concurrent())

架构

Layer 4 ─ extensions/        # Pluggy 扩展系统
Layer 3 ─ testing/           # Fixtures、数据构建、插件
Layer 2 ─ infrastructure/    # Bootstrap、配置、日志、Runtime
Layer 1 ─ clients/…          # HTTP、数据库、消息、存储
Layer 0 ─ common/            # 异常与基础类型

文档

完整文档请访问 GitHub 仓库


许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

df_test_framework-3.37.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

df_test_framework-3.37.0-py3-none-any.whl (546.3 kB view details)

Uploaded Python 3

File details

Details for the file df_test_framework-3.37.0.tar.gz.

File metadata

  • Download URL: df_test_framework-3.37.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for df_test_framework-3.37.0.tar.gz
Algorithm Hash digest
SHA256 060152226d72f23dc1f540e53cac0b54cabb6f4c2854d57cb10ae024c87f1ca2
MD5 39ed6c54488ad730d16404c02f3b442f
BLAKE2b-256 f35617cbf1daca1b7d5d3b27cae6e058dc6b44f27fd4b5a08268dc02c364a9e3

See more details on using hashes here.

File details

Details for the file df_test_framework-3.37.0-py3-none-any.whl.

File metadata

File hashes

Hashes for df_test_framework-3.37.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d2d16e7660d0726bc1563e96220714e5ffde3c497a8349b553d1727b89e3d2f0
MD5 76ed7f2620bf92f6c75675fdb2c09294
BLAKE2b-256 2215005c788b9c3107d59cc5c40558f001a60746317fac7a26ec69822c06b62b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page