# Test with multiple test cases using parametrize @pytest.mark.parametrize("a, b, expected", [ (4, 2, 2), (10, 2, 5), (-6, 2, -3), (0, 1, 0) ]) def test_divide(calculator, a, b, expected): assert calculator.divide(a, b) == expected # Test exception handling def test_divide_by_zero(calculator): with pytest.raises(ValueError) as exc_info: calculator.divide(1, 0) assert str(exc_info.value) == "Cannot divide by zero" # Test class demonstrating grouping related tests class TestCalculatorClass: def test_add_positive_numbers(self, calculator): assert calculator.add(1, 2) == 3 def test_add_negative_numbers(self, calculator): assert calculator.add(-1, -2) == -3 @pytest.mark.skip(reason="Feature not implemented yet") def test_multiply(self, calculator): assert calculator.multiply(2, 3) == 6 # Custom marker example @pytest.mark.slow def test_slow_operation(calculator): # Simulate a slow test import time time.sleep(0.1) assert calculator.add(1, 1) == 2