view tests/test_included.py @ 265:d3852c5beff9

https://docs.pytest.org/en/latest/goodpractices.html
author Jeff Hammel <k0scist@gmail.com>
date Fri, 01 Sep 2017 09:34:56 -0700
parents 15ade7ad64da
children
line wrap: on
line source

"""
tests for templates included in the package
"""

included_templates = set(['python-package'])

import shutil
import tempfile
from makeitso.makeitso import get_entry_points

def test_included_template():
    """ensure we are packaging included template correctly"""

    # ensure template is present in entry points
    entry_points = get_entry_points()
    assert included_templates.issubset(entry_points)

    # render each template
    for template_name in included_templates:
        template = entry_points[template_name]()

        # get the variables
        missing = template.missing()
        variables = {variable: variable
                     for variable in missing}

        # render
        tmpdir = tempfile.mkdtemp()
        try:
            template.substitute(variables, output=tmpdir)
        finally:
            shutil.rmtree(tmpdir)