Ejemplo n.º 1
0
def test_inheritance_special_cases():
    # _mk_exception should transform Exception to JoblibException
    assert_true(
        my_exceptions._mk_exception(Exception)[0] is
        my_exceptions.JoblibException)

    # Subclasses of JoblibException should be mapped to
    # JoblibException by _mk_exception
    for exception in [
            my_exceptions.JoblibException, my_exceptions.TransportableException
    ]:
        assert_true(
            my_exceptions._mk_exception(exception)[0] is
            my_exceptions.JoblibException)

    # Non-inheritable exception classes should be mapped to
    # JoblibException by _mk_exception. That can happen with classes
    # generated with SWIG. See
    # https://github.com/joblib/joblib/issues/269 for a concrete
    # example.
    non_inheritable_classes = [type(lambda: None), bool]
    for exception in non_inheritable_classes:
        assert_true(
            my_exceptions._mk_exception(exception)[0] is
            my_exceptions.JoblibException)
Ejemplo n.º 2
0
def test_inheritance_special_cases():
    # _mk_exception should transform Exception to JoblibException
    assert_true(my_exceptions._mk_exception(Exception)[0] is
                my_exceptions.JoblibException)

    # Subclasses of JoblibException should be mapped to
    # JoblibException by _mk_exception
    for exception in [my_exceptions.JoblibException,
                      my_exceptions.TransportableException]:
        assert_true(my_exceptions._mk_exception(exception)[0] is
                    my_exceptions.JoblibException)
Ejemplo n.º 3
0
def test_inheritance_special_cases():
    # _mk_exception should transform Exception to JoblibException
    assert_true(
        my_exceptions._mk_exception(Exception)[0] is
        my_exceptions.JoblibException)

    # Subclasses of JoblibException should be mapped to
    # JoblibException by _mk_exception
    for exception in [
            my_exceptions.JoblibException, my_exceptions.TransportableException
    ]:
        assert_true(
            my_exceptions._mk_exception(exception)[0] is
            my_exceptions.JoblibException)
Ejemplo n.º 4
0
def test_inheritance():
    assert_true(isinstance(my_exceptions.JoblibNameError(), NameError))
    assert_true(
        isinstance(my_exceptions.JoblibNameError(),
                   my_exceptions.JoblibException))
    assert_true(my_exceptions.JoblibNameError is my_exceptions._mk_exception(
        NameError)[0])
Ejemplo n.º 5
0
def test_inheritance_special_cases():
    # _mk_exception should transform Exception to JoblibException
    assert (my_exceptions._mk_exception(Exception)[0] is
            my_exceptions.JoblibException)

    # Subclasses of JoblibException should be mapped to
    # JoblibException by _mk_exception
    for exception in [my_exceptions.JoblibException,
                      my_exceptions.TransportableException]:
        assert (my_exceptions._mk_exception(exception)[0] is
                my_exceptions.JoblibException)

    # Non-inheritable exception classes should be mapped to
    # JoblibException by _mk_exception. That can happen with classes
    # generated with SWIG. See
    # https://github.com/joblib/joblib/issues/269 for a concrete
    # example.
    non_inheritable_classes = [type(lambda: None), bool]
    for exception in non_inheritable_classes:
        assert (my_exceptions._mk_exception(exception)[0] is
                my_exceptions.JoblibException)
Ejemplo n.º 6
0
def test__mk_exception():
    # Check that _mk_exception works on a bunch of different exceptions
    for klass in (Exception, TypeError, SyntaxError, ValueError,
                  ImportError, CustomException, CustomException2):
        message = 'This message should be in the exception repr'
        exc = my_exceptions._mk_exception(klass)[0](
            message, 'some', 'other', 'args', 'that are not', 'in the repr')
        exc_repr = repr(exc)

        assert isinstance(exc, klass)
        assert isinstance(exc, my_exceptions.JoblibException)
        assert exc.__class__.__name__ in exc_repr
        assert message in exc_repr
Ejemplo n.º 7
0
def test__mk_exception():
    # Check that _mk_exception works on a bunch of different exceptions
    for klass in (Exception, TypeError, SyntaxError, ValueError, ImportError,
                  CustomException, CustomException2):
        message = 'This message should be in the exception repr'
        exc = _mk_exception(klass)[0](message, 'some', 'other', 'args',
                                      'that are not', 'in the repr')
        exc_repr = repr(exc)

        assert isinstance(exc, klass)
        assert isinstance(exc, JoblibException)
        assert exc.__class__.__name__ in exc_repr
        assert message in exc_repr
Ejemplo n.º 8
0
def test_inheritance():
    assert isinstance(my_exceptions.JoblibNameError(), NameError)
    assert isinstance(my_exceptions.JoblibNameError(),
                      my_exceptions.JoblibException)
    assert (my_exceptions.JoblibNameError is
            my_exceptions._mk_exception(NameError)[0])
Ejemplo n.º 9
0
def test__mk_exception():
    # Check that _mk_exception works on a bunch of different exceptions
    for klass in (Exception, TypeError, SyntaxError, ValueError,
                  AssertionError):
        e = my_exceptions._mk_exception(klass)[0]('Some argument')
        assert_true('Some argument' in repr(e))
Ejemplo n.º 10
0
def test_inheritance():
    assert isinstance(JoblibNameError(), NameError)
    assert isinstance(JoblibNameError(), JoblibException)
    assert (JoblibNameError is _mk_exception(NameError)[0])