Skip to main content

一个轻量级的Python测试框架,提供简洁的测试运行和彩色输出功能。

Project description

Brief-Develop

一个轻量级的Python测试框架,提供简洁的测试运行和彩色输出功能。

功能特性

  • 🎨 彩色终端输出,提升测试结果的可读性
  • 📊 自动统计测试通过率
  • 🧪 支持正常测试和异常测试
  • 🔧 简单易用的API设计
  • 📦 轻量级无依赖(仅需termcolor)

安装

使用pip安装

pip install brief_develop

快速开始

基本用法

from brief_develop import BriefTest

# 创建测试实例
brief_test = BriefTest()

# 运行正常测试
def test_addition(a,b):
    return a+b

brief_test.run_test(    test_func        = lambda:test_addition(1,1),
                        detail           = lambda:f"test_addition 功能测试",
                        expected_source  = lambda:test_addition(1,1),
                        expected_message = 2
                    )

# 运行异常测试
def test_division_by_zero():
    1 / 0

brief_test.run_test(    test_func        = lambda: test_division_by_zero(),
                        detail           = lambda:f"test_division_by_zero 功能测试",
                        expected_message = "division by zero"
                    )

# 获取测试统计
print(f"测试通过率: {brief_test.get_stats()}%")

API文档

BriefTest类

__init__()

初始化测试实例。

print_Brief_Test(message: str, color: str = None)

打印彩色消息到终端。

  • message: 要显示的消息
  • color: 颜色名称(如 'red', 'green', 'blue' 等)

run_test(test_func, detail=None, expected_source=None, expected_message=None)

运行单个测试用例。

  • test_func: 测试函数或可调用对象
  • detail: 测试描述信息
  • expected_source: 期望的返回值(正常测试)
  • expected_message: 期望的异常消息(异常测试)

get_stats()

获取测试统计信息,返回通过率百分比。

项目结构

brief_develop/
├── src/
│   └── brief_develop/
│       ├── __init__.py      # 包初始化文件
│       └── module.py        # 主要功能实现
├── .gitignore              # Git忽略规则
├── requirements.txt        # 项目依赖
├── LICENSE                # 许可证文件
└── README.md              # 项目说明文档

贡献指南

欢迎提交Issue和Pull Request来改进这个项目。在提交代码前请确保:

  1. 所有现有测试通过
  2. 新增功能包含相应的测试用例
  3. 代码风格符合项目规范

许可证

本项目基于MIT许可证开源 - 详见LICENSE文件。

版本信息

  • v1.0.0 - 初始版本发布
    • 基础测试框架功能
    • 彩色输出支持
    • 测试统计功能

作者

  • hh66dw - 项目创建者和维护者

第三方库致谢 (Acknowledgements)

本项目得益于以下优秀的开源库:

termcolor - Copyright (c) 2008-2011 Volvox Development Team - 基于MIT许可证

感谢所有开源贡献者的辛勤工作。

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

brief_develop-1.0.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

brief_develop-1.0.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file brief_develop-1.0.0.tar.gz.

File metadata

  • Download URL: brief_develop-1.0.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for brief_develop-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f4eae6d27c6a3ccc34d5915cb2a9482737f635d6dba56eb2577a827492b15f7b
MD5 32a9d9c3e43b448945f533d7964701b7
BLAKE2b-256 639c245ecfeeeef0f70a40ece4467acb41a61a07f81ffa01d90cf1ee111e42b6

See more details on using hashes here.

File details

Details for the file brief_develop-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: brief_develop-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.1

File hashes

Hashes for brief_develop-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 33600dcbf5d82f4f16c9ac66c479c00a45cdb010057ef509b33448e99f2110a3
MD5 8c1de988e0bdc668ccdc064e9e858727
BLAKE2b-256 db9fb03e6df6bae0b3c1ef3803afcfc0865437150ddf150b561526ff4366ff91

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