annotate examples/doctest.txt @ 155:386a44a52139

moving to a thing with script template
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 05 Jun 2013 13:38:23 -0700
parents de1ecefe301c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 MakeItSo!
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 =========
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
4 A filesystem templating system for rapid deploy of projects
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
5
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
6 Boilerplate::
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 >>> import makeitso
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 >>> import os
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
10 >>> import shutil
116
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
11 >>> import sys
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
12 >>> import tempfile
116
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
13 >>> from subprocess import call
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 >>> from StringIO import StringIO
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
16 Basic functionality::
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
18 >>> example = os.path.join(here, 'example.txt')
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 >>> template = makeitso.PolyTemplate([example], interactive=False)
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 >>> template.missing()
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 set(['name'])
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
22 >>> template.substitute(dict(name='foo'))
36
0cba953a03ca fixed single-file test case
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
23 Hello foo
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
25 Substitute to a buffer::
35
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26
7e47ff4b0cd3 started writing tests; what a surprise, everything is broken ;)
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 >>> buffer = StringIO()
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
28 >>> template = makeitso.PolyTemplate([example], interactive=False)
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
29 >>> template.substitute(dict(name='bar'), output=buffer)
36
0cba953a03ca fixed single-file test case
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
30 >>> buffer.getvalue().strip()
0cba953a03ca fixed single-file test case
Jeff Hammel <jhammel@mozilla.com>
parents: 35
diff changeset
31 'Hello bar'
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
32
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
33 Substitute to a file::
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
34
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
35 >>> buffer = tempfile.mktemp()
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
36 >>> template = makeitso.PolyTemplate([example], interactive=False)
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
37 >>> template.substitute(dict(name='fleem'), buffer)
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
38 >>> file(buffer).read().strip()
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
39 'Hello fleem'
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
40 >>> os.remove(buffer)
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
41
91
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
42 Including a file::
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
43
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
44 >>> include_example = os.path.join(here, 'include-example.txt')
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
45 >>> buffer = tempfile.mktemp()
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
46 >>> template = makeitso.PolyTemplate([include_example], interactive=False)
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
47 >>> template.substitute({}, buffer)
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
48 >>> os.remove(buffer)
672d2d3ee322 document a bit and add a test for an include example
Jeff Hammel <jhammel@mozilla.com>
parents: 90
diff changeset
49
65
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
50 Directory case::
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
51
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
52 >>> exampledir = os.path.join(here, 'directory-example')
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
53 >>> tempdir = tempfile.mkdtemp()
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
54 >>> template = makeitso.PolyTemplate([exampledir], interactive=False)
37
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
55 >>> sorted(template.missing())
7cee2869bd7b stub out directory example
Jeff Hammel <jhammel@mozilla.com>
parents: 36
diff changeset
56 ['bar', 'foo', 'subdir']
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
57 >>> template.substitute(dict(foo='It', bar='life', subdir='mysubdir'), output=tempdir)
39
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
58 >>> sorted(os.listdir(tempdir))
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
59 ['foo.txt', 'mysubdir']
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
60 >>> file(os.path.join(tempdir, 'foo.txt')).read().strip()
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
61 'It is a wonderful life'
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
62 >>> os.listdir(os.path.join(tempdir, 'mysubdir'))
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
63 ['life.txt']
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
64 >>> file(os.path.join(tempdir, 'mysubdir', 'life.txt')).read().strip()
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
65 'It'
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
66 >>> shutil.rmtree(tempdir)
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
67
65
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
68 Mixed case::
39
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
69
51
9a0014a760d1 missed an interactive=False
Jeff Hammel <jhammel@mozilla.com>
parents: 40
diff changeset
70 >>> template = makeitso.PolyTemplate([example, exampledir], interactive=False)
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
71 >>> variables = sorted(template.missing())
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
72 >>> variables
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
73 ['bar', 'foo', 'name', 'subdir']
39
a2cdce0108e1 get directory substitution sorta working; start stubbing mixed case
Jeff Hammel <jhammel@mozilla.com>
parents: 38
diff changeset
74
65
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
75 You need to provide output for mixing files and directory templates::
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
76
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
77 >>> variables = dict([(i, i.title()) for i in variables])
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
78 >>> try:
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
79 ... template.substitute(variables)
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
80 ... except AssertionError, e:
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
81 ... pass
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
82 >>> e
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
83 AssertionError()
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
84
65
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
85 Provide an output::
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
86
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
87 >>> template = makeitso.PolyTemplate([example, exampledir], interactive=False)
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
88 >>> template.substitute(variables, tempdir)
40
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
89 >>> sorted(os.listdir(tempdir))
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
90 ['Subdir', 'example.txt', 'foo.txt']
6b4c8f23192f test and fix mixed output case
Jeff Hammel <jhammel@mozilla.com>
parents: 39
diff changeset
91 >>> shutil.rmtree(tempdir)
65
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
92
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
93 Test API templates::
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
94
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
95 >>> from makeitso.template import MakeItSoTemplate, Variable
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
96 >>> class MyTemplate(MakeItSoTemplate):
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
97 ... name = 'foo'
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
98 ... templates = ['example.txt']
0152741621c1 check in a failing test wrt location
Jeff Hammel <jhammel@mozilla.com>
parents: 51
diff changeset
99 ... vars = [Variable(name='name', default='bar')]
67
a0f7bfa98755 API templates now hobble along on their own two feet
Jeff Hammel <jhammel@mozilla.com>
parents: 65
diff changeset
100 >>> buffer = tempfile.mktemp()
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
101 >>> apitemplate = MyTemplate(interactive=False)
100
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
102 >>> apitemplate.missing()
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
103 set([])
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
104 >>> apitemplate.substitute({}, buffer)
67
a0f7bfa98755 API templates now hobble along on their own two feet
Jeff Hammel <jhammel@mozilla.com>
parents: 65
diff changeset
105 >>> file(buffer).read().strip()
a0f7bfa98755 API templates now hobble along on their own two feet
Jeff Hammel <jhammel@mozilla.com>
parents: 65
diff changeset
106 'Hello bar'
a0f7bfa98755 API templates now hobble along on their own two feet
Jeff Hammel <jhammel@mozilla.com>
parents: 65
diff changeset
107 >>> os.remove(buffer)
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
108
100
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
109 If you dont use the defaults, then you will get a missing variable::
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
110
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
111 >>> apitemplate.usedefaults = False
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
112 >>> apitemplate.missing()
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
113 set(['name'])
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
114 >>> try:
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
115 ... apitemplate.substitute({})
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
116 ... except Exception, e:
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
117 ... pass
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
118 >>> isinstance(e, makeitso.MissingVariablesException)
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
119 True
b54898f7d8a9 now API template variables seem to work
Jeff Hammel <jhammel@mozilla.com>
parents: 95
diff changeset
120
95
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
121 Test CLI handler:
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
122
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
123 >>> from makeitso.cli import MakeItSoCLI
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
124 >>> cli = MakeItSoCLI(MyTemplate)
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
125 >>> buffer = tempfile.mktemp()
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
126 >>> cli(buffer)
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
127 >>> os.remove(buffer)
e74baa8e6df4 fix CLI interface a bit....write a test for it
Jeff Hammel <jhammel@mozilla.com>
parents: 91
diff changeset
128
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
129 Test to make sure permissions are preserved. This won't work on windows::
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
130
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
131 >>> buffer = tempfile.mktemp()
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
132 >>> f = file(buffer, 'w')
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
133 >>> print >> f, '#!/bin/bash\necho foo'
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
134 >>> f.close()
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
135 >>> os.chmod(buffer, 0755)
88
712a6d358083 fixed output broke other things
Jeff Hammel <jhammel@mozilla.com>
parents: 87
diff changeset
136 >>> uritemplate = makeitso.URITemplate(example, interactive=False)
90
26b9c3bba04e make the api for substitute() variables, output
Jeff Hammel <jhammel@mozilla.com>
parents: 88
diff changeset
137 >>> uritemplate.substitute(dict(name='bar'), buffer)
87
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
138 >>> ('%o' % os.stat(buffer).st_mode).endswith('755')
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
139 True
3571417ef92e interpolate file permissions
Jeff Hammel <jhammel@mozilla.com>
parents: 67
diff changeset
140 >>> os.remove(buffer)
115
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
141
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
142 Test python package template using the entry point::
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
143
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
144 >>> 'python-package' in makeitso.get_entry_points()
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
145 True
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
146 >>> template = makeitso.PolyTemplate(['python-package'], interactive=False)
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
147 >>> missing = template.missing()
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
148 >>> sorted(missing)
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
149 ['author', 'description', 'email', 'repo', 'url']
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
150 >>> tempdir = tempfile.mkdtemp()
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
151 >>> variables = dict([(i, i) for i in missing])
116
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
152 >>> projdir = os.path.join(tempdir, 'MyProject')
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
153 >>> template.substitute(variables, output=projdir)
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
154
117
de1ecefe301c minor docstring correction
Jeff Hammel <jhammel@mozilla.com>
parents: 116
diff changeset
155 Make sure you actually get a package::
116
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
156
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
157 >>> cwd = os.getcwd()
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
158 >>> os.chdir(projdir)
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
159 >>> os.path.exists('setup.py')
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
160 True
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
161 >>> call([sys.executable, 'setup.py', 'egg_info'])
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
162 0
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
163 >>> call([sys.executable, 'setup.py', 'sdist'])
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
164 0
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
165 >>> os.path.exists('dist') and os.path.isdir('dist')
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
166 True
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
167 >>> len(os.listdir('dist')) > 0
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
168 True
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
169 >>> os.chdir(cwd)
115
7dbc3cdadffe add a test for the python-package template
Jeff Hammel <jhammel@mozilla.com>
parents: 100
diff changeset
170 >>> shutil.rmtree(tempdir)
116
908e9a653668 fix a syntax error in the python template thanks to some friendly tests
Jeff Hammel <jhammel@mozilla.com>
parents: 115
diff changeset
171