Exemple #1
0
def test_versionerror_str_def(msg, min_api_version, api_version):
    """All tests for VersionError.str_def()."""

    exc = VersionError(msg, min_api_version, api_version)

    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(' min_api_version={!r};'.format(min_api_version)) >= 0
    assert str_def.find(' api_version={!r};'.format(api_version)) >= 0
    def test_versionerror_str(self, msg, min_api_version, api_version):
        """All tests for VersionError.__str__()."""

        exc = VersionError(msg, min_api_version, api_version)

        exp_str = str(exc.args[0])

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

        assert str_str == exp_str
    def test_versionerror_repr(self, msg, min_api_version, api_version):
        """All tests for VersionError.__repr__()."""

        exc = VersionError(msg, min_api_version, api_version)

        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_versionerror_initial_attrs(self, arg_names, args):
        """Test initial attributes of VersionError."""

        msg, min_api_version, api_version = args
        posargs, kwargs = func_args(args, arg_names)

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

        assert isinstance(exc, Error)
        assert len(exc.args) == 1
        assert exc.args[0] == msg
        assert exc.min_api_version == min_api_version
        assert exc.api_version == api_version