Merge lp:~javier.collado/utah/static_anaysis_fixes_2 into lp:utah
- static_anaysis_fixes_2
- Merge into dev
Proposed by
Javier Collado
Status: | Merged |
---|---|
Merged at revision: | 493 |
Proposed branch: | lp:~javier.collado/utah/static_anaysis_fixes_2 |
Merge into: | lp:utah |
Diff against target: |
564 lines (+223/-85) 9 files modified
examples/run_install_test.py (+64/-22) examples/run_test_vm.py (+41/-12) examples/run_utah_tests.py (+55/-22) utah/client/runner.py (+8/-4) utah/client/self_test.py (+34/-13) utah/client/state_agent.py (+2/-2) utah/client/testcase.py (+13/-6) utah/client/testsuite.py (+6/-3) utah/commandstr.py (+0/-1) |
To merge this branch: | bzr merge lp:~javier.collado/utah/static_anaysis_fixes_2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Max Brustkern (community) | Approve | ||
Review via email: mp+115948@code.launchpad.net |
Commit message
Description of the change
More static analysis fixes.
This time, the work on breaking up long lines has started. I hope you agree on trying to avoid long lines as much as possible.
To post a comment you must log in.
Revision history for this message
Javier Collado (javier.collado) wrote : | # |
Yes, I've run the client and didn't get any problem.
Anyway, this kind of use of parentheses is fine since they are only grouping things from different lines into one statement. Unless a comma is added before the closing parenthesis, this won't be transformed into a one element tuple.
Revision history for this message
Max Brustkern (nuclearbob) wrote : | # |
All right, good to know, thanks.
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'examples/run_install_test.py' |
2 | --- examples/run_install_test.py 2012-07-18 13:48:03 +0000 |
3 | +++ examples/run_install_test.py 2012-07-20 10:57:30 +0000 |
4 | @@ -14,24 +14,53 @@ |
5 | |
6 | |
7 | def get_parser(): |
8 | - parser = argparse.ArgumentParser(description='Provision a machine and run one or more UTAH runlists there.', epilog="For example:\n\t%(prog)s -s oneiric -t server -a i386 /usr/share/utah/client/examples/master.run 'http://people.canonical.com/~max/max_test.run'", formatter_class=argparse.RawDescriptionHelpFormatter) |
9 | - parser.add_argument('runlists', metavar='runlist', nargs='+', help='URLs of runlist files to run') |
10 | - parser.add_argument('-m', '--machinetype', choices=('physical', 'virtual'), default='virtual', help='Type of machine to provision') |
11 | - parser.add_argument('-e', '--emulator', help='Emulator to use (kvm and qemu are supported, kvm will be favored if available)') |
12 | - parser.add_argument('-i', '--image', help='Image/ISO file to use for installation') |
13 | - parser.add_argument('-k', '--kernel', help='Kernel file to use for installation') |
14 | - parser.add_argument('-r', '--initrd', help='InitRD file to use for installation') |
15 | - parser.add_argument('-p', '--preseed', help='Preseed file to use for installation') |
16 | - parser.add_argument('-b', '--boot', help='Boot arguments for initial installation') |
17 | - parser.add_argument('-x', '--xml', help='XML VM definition file') |
18 | - parser.add_argument('-g', '--gigabytes', action='append', help='Size in gigabytes of virtual disk, specify more than once for multiple disks') |
19 | - parser.add_argument('-s', '--series', choices=('hardy', 'lucid', 'natty', 'oneiric', 'precise', 'quantal'), help='Series to use for installation') |
20 | - parser.add_argument('-t', '--type', choices=('desktop', 'server', 'mini', 'alternate'), help='Install type to use for installation') |
21 | - parser.add_argument('-a', '--arch', choices=('i386', 'amd64', 'arm'), help='Architecture to use for installation') |
22 | - parser.add_argument('-v', '--variant', help='Variant of architecture, i.e., armel, armhf') |
23 | - parser.add_argument('-n', '--no-destroy', action='store_true', help='Preserve machine after tests have run') |
24 | - parser.add_argument('-d', '--debug', action='store_true', help='Enable debug logging') |
25 | - parser.add_argument('-j', '--json', action='store_true', help='Enable json logging (Default is YAML)') |
26 | + parser = argparse.ArgumentParser( |
27 | + description=('Provision a machine ' |
28 | + 'and run one or more UTAH runlists there.'), |
29 | + epilog=("For example:\n" |
30 | + "\t%(prog)s -s oneiric -t server -a i386 " |
31 | + "/usr/share/utah/client/examples/master.run " |
32 | + "'http://people.canonical.com/~max/max_test.run'"), |
33 | + formatter_class=argparse.RawDescriptionHelpFormatter) |
34 | + parser.add_argument('runlists', metavar='runlist', nargs='+', |
35 | + help='URLs of runlist files to run') |
36 | + parser.add_argument('-m', '--machinetype', choices=('physical', 'virtual'), |
37 | + default='virtual', help='Type of machine to provision') |
38 | + parser.add_argument('-e', '--emulator', |
39 | + help=('Emulator to use (kvm and qemu are supported, ' |
40 | + 'kvm will be favored if available)')) |
41 | + parser.add_argument('-i', '--image', |
42 | + help='Image/ISO file to use for installation') |
43 | + parser.add_argument('-k', '--kernel', |
44 | + help='Kernel file to use for installation') |
45 | + parser.add_argument('-r', '--initrd', |
46 | + help='InitRD file to use for installation') |
47 | + parser.add_argument('-p', '--preseed', |
48 | + help='Preseed file to use for installation') |
49 | + parser.add_argument('-b', '--boot', |
50 | + help='Boot arguments for initial installation') |
51 | + parser.add_argument('-x', '--xml', |
52 | + help='XML VM definition file') |
53 | + parser.add_argument('-g', '--gigabytes', action='append', |
54 | + help=('Size in gigabytes of virtual disk, ' |
55 | + 'specify more than once for multiple disks')) |
56 | + parser.add_argument('-s', '--series', |
57 | + choices=('hardy', 'lucid', 'natty', |
58 | + 'oneiric', 'precise', 'quantal'), |
59 | + help='Series to use for installation') |
60 | + parser.add_argument('-t', '--type', |
61 | + choices=('desktop', 'server', 'mini', 'alternate'), |
62 | + help='Install type to use for installation') |
63 | + parser.add_argument('-a', '--arch', choices=('i386', 'amd64', 'arm'), |
64 | + help='Architecture to use for installation') |
65 | + parser.add_argument('-v', '--variant', |
66 | + help='Variant of architecture, i.e., armel, armhf') |
67 | + parser.add_argument('-n', '--no-destroy', action='store_true', |
68 | + help='Preserve machine after tests have run') |
69 | + parser.add_argument('-d', '--debug', action='store_true', |
70 | + help='Enable debug logging') |
71 | + parser.add_argument('-j', '--json', action='store_true', |
72 | + help='Enable json logging (Default is YAML)') |
73 | return parser |
74 | |
75 | |
76 | @@ -56,7 +85,12 @@ |
77 | |
78 | try: |
79 | inventory = utah.provisioning.inventory.TinySQLiteInventory() |
80 | - machine = inventory.request(utah.provisioning.vm.CustomVM, arch=args.arch, boot=args.boot, debug=args.debug, disksizes=args.gigabytes, dlpercentincrement=10, emulator=args.emulator, image=args.image, initrd=args.initrd, installtype=args.type, kernel=args.kernel, new=True, preseed=args.preseed, series=args.series, xml=args.xml) |
81 | + machine = inventory.request(utah.provisioning.vm.CustomVM, |
82 | + arch=args.arch, boot=args.boot, debug=args.debug, |
83 | + disksizes=args.gigabytes, dlpercentincrement=10, |
84 | + emulator=args.emulator, image=args.image, initrd=args.initrd, |
85 | + installtype=args.type, kernel=args.kernel, new=True, |
86 | + preseed=args.preseed, series=args.series, xml=args.xml) |
87 | for logger in [machine.logger] + machine.logger.handlers: |
88 | if logger.level > logging.INFO: |
89 | logger.setLevel(logging.INFO) |
90 | @@ -64,11 +98,19 @@ |
91 | for runlist in args.runlists: |
92 | locallist = urllib.urlretrieve(runlist)[0] |
93 | listname = os.path.split(runlist)[1] |
94 | - remotelog = os.path.normpath(os.path.join(config.logpath, machine.name + '_' + listname + '_tmp')) |
95 | - locallog = os.path.normpath(os.path.join(config.logpath, machine.name + '_' + listname + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime()) + suffix)) |
96 | + remotelog = os.path.join(config.logpath, |
97 | + machine.name + '_' + listname + '_tmp') |
98 | + remotelog = os.path.normpath(remotelog) |
99 | + locallog = os.path.join(config.logpath, |
100 | + machine.name + '_' + listname |
101 | + + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime()) |
102 | + + suffix) |
103 | + locallog = os.path.normpath(locallog) |
104 | try: |
105 | machine.uploadfiles([locallist], os.path.normpath('/tmp')) |
106 | - machine.run('utah' + extraopts + ' -r /tmp/' + os.path.split(locallist)[1] + ' -o ' + remotelog, root=True) |
107 | + options = (' -r /tmp/' + os.path.split(locallist)[1] |
108 | + + ' -o ' + remotelog) |
109 | + machine.run('utah' + extraopts + options, root=True) |
110 | machine.downloadfiles([remotelog], locallog) |
111 | print('Test log copied to ' + locallog) |
112 | locallogs.append(locallog) |
113 | |
114 | === modified file 'examples/run_test_vm.py' |
115 | --- examples/run_test_vm.py 2012-07-18 13:48:03 +0000 |
116 | +++ examples/run_test_vm.py 2012-07-20 10:57:30 +0000 |
117 | @@ -14,14 +14,34 @@ |
118 | |
119 | |
120 | def get_parser(): |
121 | - parser = argparse.ArgumentParser(description='Create a virtual machine and run a UTAH runlist there.', epilog="For example:\n\t%(prog)s -s oneiric -t server -a i386 /usr/share/utah/client/examples/master.run 'http://people.canonical.com/~max/max_test.run'", formatter_class=argparse.RawDescriptionHelpFormatter) |
122 | - parser.add_argument('runlists', metavar='runlist', nargs='+', help='URLs of runlist files to run') |
123 | - parser.add_argument('-s', '--series', choices=('hardy', 'lucid', 'natty', 'oneiric', 'precise', 'quantal'), default='oneiric', help='Series to use for VM creation') |
124 | - parser.add_argument('-t', '--type', choices=('desktop', 'server', 'mini', 'alternate'), default='server', help='Install type to use for VM creation') |
125 | - parser.add_argument('-a', '--arch', choices=('i386', 'amd64'), default='i386', help='Architecture to use for VM creation') |
126 | - parser.add_argument('-n', '--no-destroy', action='store_true', help='Preserve VM after tests have run') |
127 | - parser.add_argument('-d', '--debug', action='store_true', help='Enable debug logging') |
128 | - parser.add_argument('-j', '--json', action='store_true', help='Enable json logging (Default is YAML)') |
129 | + parser = argparse.ArgumentParser( |
130 | + description=('Create a virtual machine ' |
131 | + 'and run a UTAH runlist there.'), |
132 | + epilog=("For example:\n" |
133 | + "\t%(prog)s -s oneiric -t server -a i386 " |
134 | + "/usr/share/utah/client/examples/master.run " |
135 | + "'http://people.canonical.com/~max/max_test.run'"), |
136 | + formatter_class=argparse.RawDescriptionHelpFormatter) |
137 | + parser.add_argument('runlists', metavar='runlist', nargs='+', |
138 | + help='URLs of runlist files to run') |
139 | + parser.add_argument('-s', '--series', |
140 | + choices=('hardy', 'lucid', 'natty', |
141 | + 'oneiric', 'precise', 'quantal'), |
142 | + default='oneiric', |
143 | + help='Series to use for VM creation') |
144 | + parser.add_argument('-t', '--type', |
145 | + choices=('desktop', 'server', 'mini', 'alternate'), |
146 | + default='server', |
147 | + help='Install type to use for VM creation') |
148 | + parser.add_argument('-a', '--arch', choices=('i386', 'amd64'), |
149 | + default='i386', |
150 | + help='Architecture to use for VM creation') |
151 | + parser.add_argument('-n', '--no-destroy', action='store_true', |
152 | + help='Preserve VM after tests have run') |
153 | + parser.add_argument('-d', '--debug', action='store_true', |
154 | + help='Enable debug logging') |
155 | + parser.add_argument('-j', '--json', action='store_true', |
156 | + help='Enable json logging (Default is YAML)') |
157 | return parser |
158 | |
159 | |
160 | @@ -53,7 +73,8 @@ |
161 | kw.update([(arg, value)]) |
162 | if args.type is not None: |
163 | kw.update([('installtype', args.type)]) |
164 | - machine = inventory.request(debug=args.debug, new=True, dlpercentincrement=10, **kw) |
165 | + machine = inventory.request(debug=args.debug, new=True, |
166 | + dlpercentincrement=10, **kw) |
167 | for logger in [machine.logger] + machine.logger.handlers: |
168 | if logger.level > logging.INFO: |
169 | logger.setLevel(logging.INFO) |
170 | @@ -61,11 +82,19 @@ |
171 | for runlist in args.runlists: |
172 | locallist = urllib.urlretrieve(runlist)[0] |
173 | listname = os.path.split(runlist)[1] |
174 | - remotelog = os.path.normpath(os.path.join(config.logpath, machine.name + '_' + listname + '_tmp')) |
175 | - locallog = os.path.normpath(os.path.join(config.logpath, machine.name + '_' + listname + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime()) + suffix)) |
176 | + remotelog = os.path.join(config.logpath, |
177 | + machine.name + '_' + listname + '_tmp') |
178 | + remotelog = os.path.normpath(remotelog) |
179 | + locallog = os.path.join(config.logpath, |
180 | + machine.name + '_' + listname |
181 | + + time.strftime('_%Y-%m-%d_%H-%m-%S', time.gmtime()) |
182 | + + suffix) |
183 | + locallog = os.path.normpath(locallog) |
184 | try: |
185 | machine.uploadfiles([locallist], os.path.normpath('/tmp')) |
186 | - machine.run('utah' + extraopts + ' -r /tmp/' + os.path.split(locallist)[1] + ' -o ' + remotelog, root=True) |
187 | + options = (' -r /tmp/' + os.path.split(locallist)[1] |
188 | + + ' -o ' + remotelog) |
189 | + machine.run('utah' + extraopts + options, root=True) |
190 | machine.downloadfiles([remotelog], locallog) |
191 | print('Test log copied to ' + locallog) |
192 | locallogs.append(locallog) |
193 | |
194 | === modified file 'examples/run_utah_tests.py' |
195 | --- examples/run_utah_tests.py 2012-07-19 09:05:22 +0000 |
196 | +++ examples/run_utah_tests.py 2012-07-20 10:57:30 +0000 |
197 | @@ -9,24 +9,53 @@ |
198 | |
199 | |
200 | def get_parser(): |
201 | - parser = argparse.ArgumentParser(description='Provision a machine and run one or more UTAH runlists there.', epilog="For example:\n\t%(prog)s -s oneiric -t server -a i386 /usr/share/utah/client/examples/master.run 'http://people.canonical.com/~max/max_test.run'", formatter_class=argparse.RawDescriptionHelpFormatter) |
202 | - parser.add_argument('runlists', metavar='runlist', nargs='+', type=url_argument, help='URLs of runlist files to run') |
203 | - parser.add_argument('-m', '--machinetype', choices=('physical', 'virtual'), default='virtual', help='Type of machine to provision') |
204 | - parser.add_argument('-e', '--emulator', help='Emulator to use (kvm and qemu are supported, kvm will be favored if available)') |
205 | - parser.add_argument('-i', '--image', type=url_argument, help='Image/ISO file to use for installation') |
206 | - parser.add_argument('-k', '--kernel', type=url_argument, help='Kernel file to use for installation') |
207 | - parser.add_argument('-r', '--initrd', type=url_argument, help='InitRD file to use for installation') |
208 | - parser.add_argument('-p', '--preseed', type=url_argument, help='Preseed file to use for installation') |
209 | - parser.add_argument('-b', '--boot', help='Boot arguments for initial installation') |
210 | - parser.add_argument('-x', '--xml', type=url_argument, help='XML VM definition file') |
211 | - parser.add_argument('-g', '--gigabytes', action='append', help='Size in gigabytes of virtual disk, specify more than once for multiple disks') |
212 | - parser.add_argument('-s', '--series', choices=('hardy', 'lucid', 'natty', 'oneiric', 'precise', 'quantal'), help='Series to use for installation') |
213 | - parser.add_argument('-t', '--type', choices=('desktop', 'server', 'mini', 'alternate'), help='Install type to use for installation') |
214 | - parser.add_argument('-a', '--arch', choices=('i386', 'amd64', 'arm'), help='Architecture to use for installation') |
215 | - parser.add_argument('-v', '--variant', help='Variant of architecture, i.e., armel, armhf') |
216 | - parser.add_argument('-n', '--no-destroy', action='store_true', help='Preserve machine after tests have run') |
217 | - parser.add_argument('-d', '--debug', action='store_true', help='Enable debug logging') |
218 | - parser.add_argument('-j', '--json', action='store_true', help='Enable json logging (Default is YAML)') |
219 | + parser = argparse.ArgumentParser( |
220 | + description=('Provision a machine ' |
221 | + 'and run one or more UTAH runlists there.'), |
222 | + epilog=("For example:\n" |
223 | + "\t%(prog)s -s oneiric -t server -a i386 " |
224 | + "/usr/share/utah/client/examples/master.run " |
225 | + "'http://people.canonical.com/~max/max_test.run'"), |
226 | + formatter_class=argparse.RawDescriptionHelpFormatter) |
227 | + parser.add_argument('runlists', metavar='runlist', nargs='+', |
228 | + type=url_argument, help='URLs of runlist files to run') |
229 | + parser.add_argument('-m', '--machinetype', choices=('physical', 'virtual'), |
230 | + default='virtual', help='Type of machine to provision') |
231 | + parser.add_argument('-e', '--emulator', |
232 | + help=('Emulator to use (kvm and qemu are supported, ' |
233 | + 'kvm will be favored if available)')) |
234 | + parser.add_argument('-i', '--image', type=url_argument, |
235 | + help='Image/ISO file to use for installation') |
236 | + parser.add_argument('-k', '--kernel', type=url_argument, |
237 | + help='Kernel file to use for installation') |
238 | + parser.add_argument('-r', '--initrd', type=url_argument, |
239 | + help='InitRD file to use for installation') |
240 | + parser.add_argument('-p', '--preseed', type=url_argument, |
241 | + help='Preseed file to use for installation') |
242 | + parser.add_argument('-b', '--boot', |
243 | + help='Boot arguments for initial installation') |
244 | + parser.add_argument('-x', '--xml', type=url_argument, |
245 | + help='XML VM definition file') |
246 | + parser.add_argument('-g', '--gigabytes', action='append', |
247 | + help=('Size in gigabytes of virtual disk, ' |
248 | + 'specify more than once for multiple disks')) |
249 | + parser.add_argument('-s', '--series', |
250 | + choices=('hardy', 'lucid', 'natty', |
251 | + 'oneiric', 'precise', 'quantal'), |
252 | + help='Series to use for installation') |
253 | + parser.add_argument('-t', '--type', |
254 | + choices=('desktop', 'server', 'mini', 'alternate'), |
255 | + help='Install type to use for installation') |
256 | + parser.add_argument('-a', '--arch', choices=('i386', 'amd64', 'arm'), |
257 | + help='Architecture to use for installation') |
258 | + parser.add_argument('-v', '--variant', |
259 | + help='Variant of architecture, i.e., armel, armhf') |
260 | + parser.add_argument('-n', '--no-destroy', action='store_true', |
261 | + help='Preserve machine after tests have run') |
262 | + parser.add_argument('-d', '--debug', action='store_true', |
263 | + help='Enable debug logging') |
264 | + parser.add_argument('-j', '--json', action='store_true', |
265 | + help='Enable json logging (Default is YAML)') |
266 | return parser |
267 | |
268 | |
269 | @@ -39,18 +68,22 @@ |
270 | args = get_parser().parse_args() |
271 | |
272 | if args.machinetype == 'physical': |
273 | - sys.stderr.write("Physical machine provisioning is not supported in this release.\n") |
274 | - sys.stderr.write("Please check the roadmap, as it will be included in a future version.\n") |
275 | + sys.stderr.write("Physical machine provisioning is not supported " |
276 | + "in this release.\n") |
277 | + sys.stderr.write("Please check the roadmap, " |
278 | + "as it will be included in a future version.\n") |
279 | sys.exit(4) |
280 | |
281 | if args.arch is not None and 'arm' in args.arch: |
282 | sys.stderr.write("ARM support is not included in this release.\n") |
283 | - sys.stderr.write("Please check the roadmap, as it will be included in a future version.\n") |
284 | + sys.stderr.write("Please check the roadmap, " |
285 | + "as it will be included in a future version.\n") |
286 | sys.exit(4) |
287 | |
288 | function = run_test_vm |
289 | |
290 | - for option in [args.boot, args.emulator, args.image, args.initrd, args.kernel, args.preseed, args.xml]: |
291 | + for option in [args.boot, args.emulator, args.image, args.initrd, |
292 | + args.kernel, args.preseed, args.xml]: |
293 | if option is not None: |
294 | from run_install_test import run_install_test |
295 | function = run_install_test |
296 | |
297 | === modified file 'utah/client/runner.py' |
298 | --- utah/client/runner.py 2012-07-18 13:48:03 +0000 |
299 | +++ utah/client/runner.py 2012-07-20 10:57:30 +0000 |
300 | @@ -80,7 +80,8 @@ |
301 | |
302 | def reset_rc_local(self): |
303 | """ |
304 | - Restore original /etc/rc.local if there is a backup otherwise remove it. |
305 | + Restore original /etc/rc.local if there is a backup |
306 | + Otherwise remove it. |
307 | """ |
308 | |
309 | # Ignore permission denied errors since we only care if a reboot is |
310 | @@ -250,8 +251,9 @@ |
311 | # Create a TestSuite |
312 | # TODO: pass master.run overrides into the test suite. |
313 | s = TestSuite(name=name, runlist_file=suite_runlist, |
314 | - includes=includes, excludes=excludes, result=self.result, |
315 | - path=self.testdir, _save_state_callback=self.save_state, |
316 | + includes=includes, excludes=excludes, |
317 | + result=self.result, path=self.testdir, |
318 | + _save_state_callback=self.save_state, |
319 | _reboot_callback=self.reboot) |
320 | self.add_suite(s) |
321 | |
322 | @@ -311,7 +313,9 @@ |
323 | def report(self): |
324 | tests_run = self.passes + self.errors + self.failures |
325 | |
326 | - output = "total: %d, passes: %d, failure: %d, error: %d" % (tests_run, self.passes, self.failures, self.errors + self.fetch_errors) |
327 | + output = ("total: %d, passes: %d, failure: %d, error: %d" |
328 | + % (tests_run, self.passes, self.failures, |
329 | + self.errors + self.fetch_errors)) |
330 | |
331 | if self.errors > 0 or self.fetch_errors > 0: |
332 | result = "ERROR" |
333 | |
334 | === modified file 'utah/client/self_test.py' |
335 | --- utah/client/self_test.py 2012-07-18 13:48:03 +0000 |
336 | +++ utah/client/self_test.py 2012-07-20 10:57:30 +0000 |
337 | @@ -135,7 +135,9 @@ |
338 | """ |
339 | Use the 'examples' test suite that's part of the UTAH package. |
340 | """ |
341 | - self.suite = testsuite.TestSuite(name='examples', path='/var/lib/utah', result_class=ResultYAML, |
342 | + self.suite = testsuite.TestSuite(name='examples', |
343 | + path='/var/lib/utah', |
344 | + result_class=ResultYAML, |
345 | _save_state_callback=state_saver) |
346 | |
347 | def test_run(self): |
348 | @@ -369,7 +371,9 @@ |
349 | def test_fetch_failed(self): |
350 | print "Starting test" |
351 | # exit 2 should be flagged as an error. |
352 | - bad_runlist_content = """---\n- name: fake_tests\n fetch_cmd: exit 2\n""" |
353 | + bad_runlist_content = ('---\n' |
354 | + '- name: fake_tests\n' |
355 | + ' fetch_cmd: exit 2\n') |
356 | runlist = '/tmp/master_fetch_fails.run' |
357 | |
358 | self.assertFalse(os.path.exists(runlist), runlist) |
359 | @@ -411,9 +415,10 @@ |
360 | """ |
361 | Test that the runner fails gracefully on missing testdir. |
362 | """ |
363 | - |
364 | self.assertRaises(exceptions.BadDir, |
365 | - Runner, result_class=self.result_class, testdir=self.bad_dir) |
366 | + Runner, |
367 | + result_class=self.result_class, |
368 | + testdir=self.bad_dir) |
369 | |
370 | def test_missing_master_runlist(self): |
371 | """ |
372 | @@ -430,7 +435,9 @@ |
373 | os.remove(tmp_master_runlist) |
374 | |
375 | self.assertRaises(exceptions.MissingFile, |
376 | - Runner, result_class=self.result_class, testdir=self.bad_dir) |
377 | + Runner, |
378 | + result_class=self.result_class, |
379 | + testdir=self.bad_dir) |
380 | |
381 | def test_runlist(self): |
382 | """ |
383 | @@ -477,9 +484,15 @@ |
384 | raise Exception("didn't print with CONFIG['DEBUG'] set to True") |
385 | |
386 | CONFIG['DEBUG'] = False |
387 | - self.assertEqual(debug_print("shouldn't be printed unless common.CONFIG['DEBUG'] is True"), CONFIG['DEBUG'], "printed with CONFIG['DEBUG'] set to False") |
388 | |
389 | - self.assertEqual(debug_print("should be printed (using 'force=True')", force=True), True) |
390 | + debug = debug_print("shouldn't be printed " |
391 | + "unless common.CONFIG['DEBUG'] is True") |
392 | + self.assertEqual(debug, |
393 | + CONFIG['DEBUG'], |
394 | + "printed with CONFIG['DEBUG'] set to False") |
395 | + debug = debug_print("should be printed (using 'force=True')", |
396 | + force=True) |
397 | + self.assertEqual(debug, True) |
398 | |
399 | CONFIG['DEBUG'] = old_debug |
400 | |
401 | @@ -497,10 +510,12 @@ |
402 | self.state_file = '/tmp/state.yaml' |
403 | |
404 | # Fail if there is already a test state file. |
405 | - self.assertFalse(os.path.exists(self.state_file), "state file (%s) already exists" % self.state_file) |
406 | + self.assertFalse(os.path.exists(self.state_file), |
407 | + "state file (%s) already exists" % self.state_file) |
408 | |
409 | self.state_agent = StateAgentYAML(state_file=self.state_file) |
410 | - self.runner = Runner(result_class=ResultYAML, state_agent=self.state_agent) |
411 | + self.runner = Runner(result_class=ResultYAML, |
412 | + state_agent=self.state_agent) |
413 | self.partial_state_file_content = partial_state_file_content |
414 | |
415 | def tearDown(self): |
416 | @@ -523,11 +538,13 @@ |
417 | def test_cleanup(self): |
418 | self.runner.save_state() |
419 | |
420 | - self.assertTrue(os.path.exists(self.state_file), "Runner failed to save state") |
421 | + self.assertTrue(os.path.exists(self.state_file), |
422 | + "Runner failed to save state") |
423 | |
424 | self.state_agent.clean() |
425 | |
426 | - self.assertFalse(os.path.exists(self.state_file), "Failed to remove state file (%s)" % self.state_file) |
427 | + self.assertFalse(os.path.exists(self.state_file), |
428 | + "Failed to remove state file (%s)" % self.state_file) |
429 | |
430 | def test_status(self): |
431 | """ |
432 | @@ -559,9 +576,13 @@ |
433 | fp.write(self.partial_state_file_content) |
434 | fp.close() |
435 | |
436 | - run_cmd('cp -r /usr/share/utah/client/examples/utah_tests /var/lib/utah/utah_tests/ #JAT') |
437 | + run_cmd('cp -r ' |
438 | + '/usr/share/utah/client/examples/utah_tests ' |
439 | + '/var/lib/utah/utah_tests/ #JAT') |
440 | |
441 | - run_cmd('cp -r /usr/share/utah/client/examples/utah_tests_sample /var/lib/utah/utah_tests_sample/ #JAT') |
442 | + run_cmd('cp -r ' |
443 | + '/usr/share/utah/client/examples/utah_tests_sample ' |
444 | + '/var/lib/utah/utah_tests_sample/ #JAT') |
445 | |
446 | state_agent = StateAgentYAML(state_file=self.state_file) |
447 | runner = Runner(state_agent=state_agent, resume=True) |
448 | |
449 | === modified file 'utah/client/state_agent.py' |
450 | --- utah/client/state_agent.py 2012-07-18 13:48:03 +0000 |
451 | +++ utah/client/state_agent.py 2012-07-20 10:57:30 +0000 |
452 | @@ -60,8 +60,8 @@ |
453 | """ |
454 | Output the state as YAML. |
455 | """ |
456 | - |
457 | - super(StateAgentYAML, self).save_state(yaml.dump(state, default_flow_style=False)) |
458 | + yaml_state = yaml.dump(state, default_flow_style=False) |
459 | + super(StateAgentYAML, self).save_state(yaml_state) |
460 | |
461 | def load_state(self): |
462 | """ |
463 | |
464 | === modified file 'utah/client/testcase.py' |
465 | --- utah/client/testcase.py 2012-07-18 11:09:47 +0000 |
466 | +++ utah/client/testcase.py 2012-07-20 10:57:30 +0000 |
467 | @@ -25,7 +25,8 @@ |
468 | type = 'userland' |
469 | |
470 | def __init__(self, name, path, command=None, result=None, timeout=0, |
471 | - _control_data=None, _save_state_callback=None, _reboot_callback=None): |
472 | + _control_data=None, _save_state_callback=None, |
473 | + _reboot_callback=None): |
474 | """ |
475 | Build a TestCase from a control file's data. |
476 | |
477 | @@ -59,8 +60,9 @@ |
478 | import os |
479 | if _control_data is None: |
480 | if os.path.exists(self.filename): |
481 | - control_data = parse_control_file(self.filename, required=required_items, |
482 | - optional=optional_items) |
483 | + control_data = parse_control_file(self.filename, |
484 | + required=required_items, |
485 | + optional=optional_items) |
486 | else: |
487 | raise MissingFile(self.filename) |
488 | else: |
489 | @@ -76,7 +78,8 @@ |
490 | self.command = command |
491 | |
492 | def __str__(self): |
493 | - return "%s: %s, %s, %s" % (self.name, self.description, self.command, self.timeout) |
494 | + return ("%s: %s, %s, %s" |
495 | + % (self.name, self.description, self.command, self.timeout)) |
496 | |
497 | def set_status(self, status): |
498 | """ |
499 | @@ -142,13 +145,17 @@ |
500 | timeout = self.timeout or 0 |
501 | self.status = "RUN" |
502 | self.save_state_callback() |
503 | - result.add_result(run_cmd(self.command, timeout=timeout, cwd=self.working_dir)) |
504 | + result.add_result(run_cmd(self.command, |
505 | + timeout=timeout, |
506 | + cwd=self.working_dir)) |
507 | |
508 | # Clean up whether 'command' failed or not. |
509 | self.cleanup(result) |
510 | |
511 | need_reboot = False |
512 | - if self.reboot == 'always' or self.reboot == 'pass' and result.status == 'PASS': |
513 | + if (self.reboot == 'always' |
514 | + or self.reboot == 'pass' |
515 | + and result.status == 'PASS'): |
516 | need_reboot = True |
517 | |
518 | self.run_status = result.result() |
519 | |
520 | === modified file 'utah/client/testsuite.py' |
521 | --- utah/client/testsuite.py 2012-07-18 11:09:47 +0000 |
522 | +++ utah/client/testsuite.py 2012-07-20 10:57:30 +0000 |
523 | @@ -34,7 +34,8 @@ |
524 | ts_setup = None |
525 | ts_cleanup = None |
526 | control_file = None |
527 | - # status is one of 'NOTRUN', 'BUILD', 'SETUP', 'INPROGRESS', 'CLEANUP', and 'DONE' |
528 | + # status is one of: |
529 | + # 'NOTRUN', 'BUILD', 'SETUP', 'INPROGRESS', 'CLEANUP', and 'DONE' |
530 | status = "NOTRUN" |
531 | save_state_callback = do_nothing |
532 | |
533 | @@ -50,7 +51,8 @@ |
534 | self.failures = 0 |
535 | self.errors = 0 |
536 | |
537 | - # work from within the testsuite's directory. eg. /var/lib/utah/examples |
538 | + # work from within the testsuite's directory. |
539 | + # eg. /var/lib/utah/examples |
540 | os.getcwd() |
541 | |
542 | if not os.path.exists(self.path): |
543 | @@ -90,7 +92,8 @@ |
544 | control_data = _control_data |
545 | elif self.control_file is not None: |
546 | control_data = parse_control_file(self.control_file, |
547 | - required=required_items, optional=optional_items) |
548 | + required=required_items, |
549 | + optional=optional_items) |
550 | |
551 | if control_data is not None: |
552 | self.__dict__.update(control_data) |
553 | |
554 | === modified file 'utah/commandstr.py' |
555 | --- utah/commandstr.py 2012-07-19 13:29:56 +0000 |
556 | +++ utah/commandstr.py 2012-07-20 10:57:30 +0000 |
557 | @@ -3,7 +3,6 @@ |
558 | """ |
559 | |
560 | |
561 | - |
562 | def commandstr(command, *args, **kw): |
563 | """ |
564 | Convert a command and argument lists into a representation of that command suitable for display to a user. |
I haven't been trying as hard as I could be. I'll try harder.
There are two spots here I'm concerned about:
326 - output = "total: %d, passes: %d, failure: %d, error: %d" % (tests_run, self.passes, self.failures, self.errors + self.fetch_errors)
327 + output = ("total: %d, passes: %d, failure: %d, error: %d"
328 + % (tests_run, self.passes, self.failures,
329 + self.errors + self.fetch_errors))
493 - return "%s: %s, %s, %s" % (self.name, self.description, self.command, self.timeout)
494 + return ("%s: %s, %s, %s"
495 + % (self.name, self.description, self.command, self.timeout))
Is this going to turn what was a string into a tuple containing a string? If you've run the client with these changes and it works, then we're fine, I just don't know the client code as well.