pytest assert message customization with variable introspection
you could use Python built-in capability to show custom exception message: assert response.status_code == 200, f”My custom msg: actual status code {response.status_code}” Or you can built a helper assert functions: def assert_status(response, status=200): # you can assert other status codes too assert response.status_code == status, \ f”Expected {status}. Actual status {response.status_code}. Response text {response.text}” # … Read more