Beispiel #1
0
def test_readtimeout_str_def(msg, details, read_timeout, read_retries):
    """All tests for ReadTimeout.str_def()."""

    exc = ReadTimeout(msg, details, read_timeout, read_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(' read_timeout={!r};'.format(read_timeout)) >= 0
    assert str_def.find(' read_retries={!r};'.format(read_retries)) >= 0
    def test_readtimeout_str(self, msg, details, read_timeout, read_retries):
        """All tests for ReadTimeout.__str__()."""

        exc = ReadTimeout(msg, details, read_timeout, read_retries)

        exp_str = str(exc.args[0])

        # Execute the code to be tested
        str_str = str(exc)

        assert str_str == exp_str
    def test_readtimeout_repr(self, msg, details, read_timeout, read_retries):
        """All tests for ReadTimeout.__repr__()."""

        exc = ReadTimeout(msg, details, read_timeout, read_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_readtimeout_initial_attrs(self, arg_names, args):
        """Test initial attributes of ReadTimeout."""

        msg, details, read_timeout, read_retries = args
        posargs, kwargs = func_args(args, arg_names)

        # Execute the code to be tested
        exc = ReadTimeout(*posargs, **kwargs)

        assert isinstance(exc, ConnectionError)
        assert len(exc.args) == 1
        assert exc.args[0] == msg
        assert exc.details == details
        assert exc.read_timeout == read_timeout
        assert exc.read_retries == read_retries