🏠 Hem
Benchmarkar
📊 Alla benchmarkar 🦖 Dinosaur v1 🦖 Dinosaur v2 ✅ To-Do List-applikationer 🎨 Kreativa fria sidor 🎯 FSACB - Ultimata uppvisningen 🌍 Översättningsbenchmark
Modeller
🏆 Topp 10 modeller 🆓 Gratis modeller 📋 Alla modeller ⚙️ Kilo Code
Resurser
💬 Promptbibliotek 📖 AI-ordlista 🔗 Användbara länkar
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)