🏠 首页
基准测试
📊 所有基准测试 🦖 恐龙 v1 🦖 恐龙 v2 ✅ 待办事项应用 🎨 创意自由页面 🎯 FSACB - 终极展示 🌍 翻译基准测试
模型
🏆 前 10 名模型 🆓 免费模型 📋 所有模型 ⚙️ 🛠️ 千行代码模式
资源
💬 💬 提示库 📖 📖 AI 词汇表 🔗 🔗 有用链接
intermediate

Generate Python Unit Tests

#python #testing #code-generation

Create comprehensive unit tests for a Python function using the unittest framework.

Act as a Python developer. Write a set of unit tests using the unittest framework for the following function. Include test cases for standard inputs, edge cases, and error handling. Function: def calculate_discount(price, discount_rate): if not 0 <= discount_rate <= 1: raise ValueError("Invalid discount rate") return price * (1 - discount_rate)