Exemple #1
0
def test_goloop_no_parent():
    ''' Attempt to generate code for a loop that has no GOInvokeSchedule
    as a parent '''
    # First create with a schedule as one is required to declare the
    # loop variable
    schedule = Schedule()
    goloop = GOLoop(loop_type="inner", parent=schedule)
    schedule.children = [goloop]
    # Now remove parent and children
    goloop.detach()
    goloop.children = []
    # Try and generate the code for this loop even though it
    # has no parent schedule and no children
    with pytest.raises(GenerationError):
        goloop.gen_code(None)
Exemple #2
0
def test_goloop_no_parent():
    ''' Attempt to generate code for a loop that has no GOInvokeSchedule
    as a parent '''
    # Attempt to create a GOLoop within a generic Schedule
    schedule = Schedule()
    with pytest.raises(GenerationError) as err:
        goloop = GOLoop(loop_type="inner", parent=schedule)
    assert ("GOLoops must always be constructed with a parent which is inside "
            "(directly or indirectly) of a GOInvokeSchedule" in str(err.value))

    # Now create it in a GOInvokeSchedule but then detach it
    schedule = GOInvokeSchedule('name', [])
    goloop = GOLoop(loop_type="inner", parent=schedule)
    schedule.children = [goloop]
    # Now remove parent and children
    goloop.detach()

    # Try and generate the code for this loop even though it
    # has no parent schedule and no children
    with pytest.raises(GenerationError):
        goloop.gen_code(None)