예제 #1
0
def run():
    print(tests.dashed_line(80,'-'))
    result   = lists.cartn(['a','b'], [1,2], ['A','B'])
    solution = [['a', 1, 'A'], ['a', 1, 'B'], ['a', 2, 'A'], ['a', 2, 'B'], ['b', 1, 'A'], ['b', 1, 'B'], ['b', 2, 'A'], ['b', 2, 'B']]
    assert result == solution, "ERROR HINT: Test 1 for lists.cartn() failed"
    print("Result = ", result,"\n")
    print("lists.cartn(): test 1 passed!")
    print(tests.dashed_line(80,'-'))
예제 #2
0
def run():
    print(tests.dashed_line(80,'-'))
    result   = lists.tail([0])
    solution =  []
    assert result == solution, "ERROR HINT: Test 2 for lists.tail() failed"
    print("Result = ", result,"\n")
    print("lists.tail(): test 2 passed!")
    print(tests.dashed_line(80,'-'))
예제 #3
0
def run():
    print(tests.dashed_line(80,'-'))
    result   = lists.head([])
    solution = None
    print("Result = ", result,"\n")
    assert result == solution, "ERROR HINT: Test 1 for lists.head() failed"
    print("lists.head(): test 1 passed!")
    print(tests.dashed_line(80,'-'))
예제 #4
0
def run():
    print(tests.dashed_line(80,'-'))
    result   = lists.dict2list({
        "a": {
            1: "A",
            2: "B"
        },
        "b": {
            3: "C",
            4: "D"
        }
        })
    solution =  [['a', 1, 'A'], ['a', 2, 'B'], ['b', 3, 'C'], ['b', 4, 'D']]
    print("Result = ", result,"\n")
    # note the result may not be the same for each run 
    # due to the lack of order in dict.
    assert sorted(result) == solution, "ERROR HINT: Test 1 for lists.dict2list() failed"
    print("lists.dict2list(): test 1 passed!")
    print(tests.dashed_line(80,'-'))
예제 #5
0
def runtests():
    print(tests.dashed_line(80))
    test_1.run()
    print(tests.dashed_line(80))