intermediate
Generate Python Unit Tests
Create comprehensive unit tests for a Python function using the unittest framework.
📝 Prompt Inhoud
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)