test_03_upper_and_concat.py 852 Bytes
Newer Older
steinbac's avatar
steinbac committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
from lorem_fixture import lorem

def list_of_uppercase(alist):

    value = []
    for item in alist:
        value.append( item.upper() )

    return value

def test_manual(benchmark,lorem):

    res = benchmark(list_of_uppercase,lorem)

    assert res[0] != lorem[0]

def map_uppercase(alist):

    value = map(str.upper, alist)

    return value

def test_map(benchmark,lorem):

    res = benchmark(map_uppercase,lorem)

    assert list(res)[0] != lorem[0]

def manual_with_locals(alist):

    up = str.upper
    value = []
    append = value.append
    for w in alist:
        append(up(w))

    return value

def test_with_locals(benchmark,lorem):

    res = benchmark(manual_with_locals,lorem)

    assert res[0] != lorem[0]

# def test_join(benchmark,lorem):

#     res = benchmark(" ".join, lorem)

#     assert res.startswith(" ".join(lorem))