Nice clean up :)
I have a few fairly minor comments. [4] needs fixing before this branch is safe to land.
[1]
+ self.assert_(wadl.startswith('<?xml '))
I think this might be better as:
from lp.testing.matchers import Startswith self.assertThat(wadl, StartsWith('<?xml '))
You'll need to inherit from lp.testing.TestCase (or, more accurately, testtools.TestCase) to get assertThat().
[2]
+ self.assert_('<html ' in html)
Same as [1].
[3]
+ return subprocess.Popen( + ['xsltproc', stylesheet, wadl_filename], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE).communicate()[0]
Unless it's useless and/or noisy, I think stderr should be left alone, so:
return subprocess.Popen( ['xsltproc', stylesheet, wadl_filename], stdout=subprocess.PIPE).communicate()[0]
I also think the exit code should be checked, so:
args = ['xsltproc', stylesheet, wadl_filename] process = subprocess.Popen(args, stdout=subprocess.PIPE) out, err = process.communicate() if process.returncode == 0: return out else raise subprocess.CalledProcessError( process.returncode, args)
This is similar to how subprocess.check_call() behaves.
[4]
-import _pythonpath -
It's ugly, looks like lint, but you'll need this.
It may be worth adding a test to show that the script can run successfully, even if it's only to show the help.
« Back to merge proposal
Nice clean up :)
I have a few fairly minor comments. [4] needs fixing before this
branch is safe to land.
[1]
+ self.assert_ (wadl.startswit h('<?xml '))
I think this might be better as:
from lp.testing.matchers import Startswith assertThat( wadl, StartsWith('<?xml '))
self.
You'll need to inherit from lp.testing.TestCase (or, more accurately,
testtools.TestCase) to get assertThat().
[2]
+ self.assert_('<html ' in html)
Same as [1].
[3]
+ return subprocess.Popen( subprocess. PIPE, subprocess. PIPE).communica te()[0]
+ ['xsltproc', stylesheet, wadl_filename],
+ stdout=
+ stderr=
Unless it's useless and/or noisy, I think stderr should be left alone,
so:
return subprocess.Popen(
['xsltproc' , stylesheet, wadl_filename],
stdout= subprocess. PIPE).communica te()[0]
I also think the exit code should be checked, so:
args = ['xsltproc', stylesheet, wadl_filename] Popen(args, stdout= subprocess. PIPE) communicate( ) CalledProcessEr ror(
process. returncode, args)
process = subprocess.
out, err = process.
if process.returncode == 0:
return out
else
raise subprocess.
This is similar to how subprocess. check_call( ) behaves.
[4]
-import _pythonpath
-
It's ugly, looks like lint, but you'll need this.
It may be worth adding a test to show that the script can run
successfully, even if it's only to show the help.