def test_error_custom_dns(program, error_code, expected_message): exc = ConnectionError('Connection aborted') exc.__context__ = socket.gaierror(error_code, "<test>") program.side_effect = exc r = http('www.google.com', tolerate_error_exit_status=True) assert r.exit_status == ExitStatus.ERROR assert expected_message in r.stderr