Example #1
0
def checkLoopsUsingIterator(loopList, index, elem):

    expectedIndex = tai.getStoredObject("checkLoopsUsingIterator", defaultValue=0)
    getUnittestObj().assertEqual(
        index, expectedIndex, "index parameter has unexpected value: %s, expected %s" % (str(index), str(expectedIndex))
    )
    getUnittestObj().assertEqual(
        elem,
        loopList[index],
        "iterated element has unexpected value: '%s', expected '%s'" % (str(elem), str(loopList[index])),
    )

    indexFromAPI = tai.getBlockIterationIndex()
    iterObjFromAPI = tai.getBlockIterationObject()
    getUnittestObj().assertEqual(
        indexFromAPI,
        expectedIndex,
        "tai.getBlockExecutionIndex() returned unexpected value: %s, expected %s"
        % (str(indexFromAPI), str(expectedIndex)),
    )
    getUnittestObj().assertEqual(
        iterObjFromAPI,
        elem,
        "tai.getBlockIterationObject() returned unexpected value: '%s', expected '%s'"
        % (str(iterObjFromAPI), str(elem)),
    )

    expectedIndex = expectedIndex + 1
    if expectedIndex == len(loopList):
        tai.removeStoredObject("checkLoopsUsingIterator")
    else:
        tai.storeObject("checkLoopsUsingIterator", expectedIndex)
Example #2
0
def checkLoopsUsingCounter(maxCounter, index):

    expectedIndex = tai.getStoredObject("checkLoopsUsingCounter", defaultValue=0)
    getUnittestObj().assertEqual(
        index, expectedIndex, "index parameter has unexpected value: %s, expected %s" % (str(index), str(expectedIndex))
    )

    indexFromAPI = tai.getBlockIterationIndex()
    getUnittestObj().assertEqual(
        indexFromAPI,
        expectedIndex,
        "tai.getBlockExecutionIndex() returned unexpected value: %s, expected %s"
        % (str(indexFromAPI), str(expectedIndex)),
    )

    expectedIndex = expectedIndex + 1
    if expectedIndex == maxCounter:
        tai.removeStoredObject("checkLoopsUsingCounter")
    else:
        tai.storeObject("checkLoopsUsingCounter", expectedIndex)