Ejemplo n.º 1
0
def test_downcast_negative():
    # Arrange
    d = Derived()

    # Act / Assert
    try:
        downcast(Other, d)
    except AssertionError:
        pass
Ejemplo n.º 2
0
def test_try_cast_negative():
    # Arrange
    d = Derived()
    b = downcast(Base, d)

    # Act
    c = try_upcast(Other, b)

    # Assert
    assert not c
Ejemplo n.º 3
0
def test_try_cast():
    # Arrange
    d = Derived()
    b = downcast(Base, d)

    # Act
    c = try_upcast(Derived, b)

    # Assert
    assert isinstance(c, Derived)
Ejemplo n.º 4
0
def test_upcast_negative():
    # Arrange
    d = Derived()
    c = downcast(Base, d)

    # Act / Assert
    try:
        d = upcast(Other, c)
    except AssertionError:
        pass
Ejemplo n.º 5
0
def test_downcast():
    # Arrange
    d = Derived()

    # Act
    b = downcast(Base, d)

    # Assert
    assert isinstance(b, Base)
    assert isinstance(b, Derived)
Ejemplo n.º 6
0
def test_upcast():
    # Arrange
    d = Derived()
    c = downcast(Base, d)

    # Act
    d = upcast(Derived, c)

    # Assert
    assert isinstance(d, Base)
    assert isinstance(d, Derived)