def subroutine_type(name):
    """Returns type of subroutine, 'setup' or 'teardown' if it has
    either of those names, or module setup or teardown, otherwise None."""
    lowername = name.lower()
    if lowername == 'setup':
        subtype = 'global setup'
    elif lowername == 'teardown':
        subtype = 'global teardown'
    elif lowername.startswith('test_'):
        subtype = 'test'
    elif 'setup_' in lowername or '_setup' in lowername:
        subtype = 'setup'
    elif 'teardown_' in lowername or '_teardown' in lowername:
        subtype = 'teardown'
    else:
        subtype = None
    return subtype