def test_connecttimeout_str_def(msg, details, connect_timeout, connect_retries): """All tests for ConnectTimeout.str_def().""" exc = ConnectTimeout(msg, details, connect_timeout, connect_retries) classname = exc.__class__.__name__ # Execute the code to be tested str_def = exc.str_def() str_def = ' ' + str_def assert str_def.find(' classname={!r};'.format(classname)) >= 0 assert str_def.find(' message={!r};'.format(msg)) >= 0 assert str_def.find(' connect_timeout={!r};'.format(connect_timeout)) >= 0 assert str_def.find(' connect_retries={!r};'.format(connect_retries)) >= 0
def test_connecttimeout_str(msg, details, connect_timeout, connect_retries): """All tests for ConnectTimeout.__str__().""" exc = ConnectTimeout(msg, details, connect_timeout, connect_retries) exp_str = str(exc.args[0]) # Execute the code to be tested str_str = str(exc) assert str_str == exp_str
def test_connecttimeout_repr(msg, details, connect_timeout, connect_retries): """All tests for ConnectTimeout.__repr__().""" exc = ConnectTimeout(msg, details, connect_timeout, connect_retries) classname = exc.__class__.__name__ # Execute the code to be tested repr_str = repr(exc) # We check the one-lined string just roughly repr_str = repr_str.replace('\n', '\\n') assert re.match(r'^{}\s*\(.*\)$'.format(classname), repr_str)
def test_connecttimeout_initial_attrs(self, arg_names, args): """Test initial attributes of ConnectTimeout.""" msg, details, connect_timeout, connect_retries = args posargs, kwargs = func_args(args, arg_names) # Execute the code to be tested exc = ConnectTimeout(*posargs, **kwargs) assert isinstance(exc, ConnectionError) assert len(exc.args) == 1 assert exc.args[0] == msg assert exc.details == details assert exc.connect_timeout == connect_timeout assert exc.connect_retries == connect_retries