@register.tag(name="loadmacros")
def do_loadmacros(parser, token):
    try:
        tag_name, filename = token.split_contents()
    except ValueError:
        raise template.TemplateSyntaxError(
            "'{0}' tag requires exactly one argument (filename)".format(
                token.contents.split()[0]))
    if filename[0] in ('"', "'") and filename[-1] == filename[0]:
        filename = filename[1:-1]
    else:
        raise template.TemplateSyntaxError(
            "Malformed argument to the {0} template tag."
            " Argument must be in quotes.".format(tag_name)
        )
    t = get_template(filename)
    try:
        # Works for Django 1.8
        nodelist = t.template.nodelist
    except AttributeError:
        # Works for Django < 1.8
        nodelist = t.nodelist
    macros = nodelist.get_nodes_by_type(DefineMacroNode)
    # make sure the _macros attribute dictionary is instantiated
    # on the parser, then add the macros to it.
    _setup_macros_dict(parser)
    for macro in macros:
        parser._macros[macro.name] = macro
    # pass macros to LoadMacrosNode so that it can
    # resolve the macros template variable kwargs on render
    return LoadMacrosNode(macros)
Teardown method.
dataset/ETHPy150Open nalourie/django-macros/build/lib/macros/templatetags/macros.py/do_loadmacros--crossover with--dataset/ETHPy150Open aerospike/aerospike-client-python/test/old_tests/_test_list_get.py/TestListGet.teardown_method