annotate tests/test_included.py @ 259:15ade7ad64da

hopefully introduce a failing test for tox install
author Jeff Hammel <k0scist@gmail.com>
date Sat, 27 May 2017 17:50:13 -0700
parents e21f013586d0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
257
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 """
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 tests for templates included in the package
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3 """
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 included_templates = set(['python-package'])
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6
259
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
7 import shutil
258
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
8 import tempfile
257
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 from makeitso.makeitso import get_entry_points
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 def test_included_template():
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 """ensure we are packaging included template correctly"""
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 # ensure template is present in entry points
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 entry_points = get_entry_points()
28d76b139fdd add test for included templates
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 assert included_templates.issubset(entry_points)
258
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
17
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
18 # render each template
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
19 for template_name in included_templates:
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
20 template = entry_points[template_name]()
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
21
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
22 # get the variables
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
23 missing = template.missing()
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
24 variables = {variable: variable
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
25 for variable in missing}
e21f013586d0 get variables and feed them right back
Jeff Hammel <k0scist@gmail.com>
parents: 257
diff changeset
26
259
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
27 # render
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
28 tmpdir = tempfile.mkdtemp()
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
29 try:
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
30 template.substitute(variables, output=tmpdir)
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
31 finally:
15ade7ad64da hopefully introduce a failing test for tox install
Jeff Hammel <k0scist@gmail.com>
parents: 258
diff changeset
32 shutil.rmtree(tmpdir)