In the test (or in a new test) try setting the spec title to something
that must be escaped - e.g. <script>...</script> - so that escaping is
demonstrated.
[4]
+ self.assertEqual(str(e),
+ '%s is already registered by <a href="%s">%s</a>.'
+ % (u'http://ubuntu.com', url, existing.title))
The order of arguments to assertEqual() is (expected, observed). When
the test fails it refers to them as "reference" and "actual"
respectively. Just switch them around.
Thanks for doing this, it's a nice improvement.
There are some minor issues with the branch as it stands, but I doubt
they'll hold you up for long.
[1]
- errormessage = _("%s is already registered by another blueprint.") %s\">%s< /a>.")
+ errormessage = _("%s is already registered by <a href=\"
I suggest using single quotes here to make it a little more readable:
errormessage = _('%s is already registered by <a href="%s">%s</a>.')
[2]
+ specification_url = canonical_
if specification is not None:
- raise LaunchpadValida
+ raise LaunchpadValida
+ (specurl, specification_url, specification.
canonical_url(None) blows up, so move the initialization of
specification_url to within the following conditional.
There should probably be a test for this too, something like:
def test_specurl_ validation_ okay(self) : makeSpecificati on() 'specurl' ].bind( spec)
field. validate( u'http:// example. com/nigelb')
spec = self.factory.
field = ISpecification[
[3]
+ raise LaunchpadValida tionError( structured( self.errormessa ge % title)) )
+ (specurl, specification_url, specification.
This is unsafe; structured() should be used slightly differently:
raise LaunchpadValida tionError(
structured( self.errormessa ge, specurl, specification_url,
specifica tion.title) )
In the test (or in a new test) try setting the spec title to something ...</script> - so that escaping is
that must be escaped - e.g. <script>
demonstrated.
[4]
+ self.assertEqua l(str(e) , ubuntu. com', url, existing.title))
+ '%s is already registered by <a href="%s">%s</a>.'
+ % (u'http://
The order of arguments to assertEqual() is (expected, observed). When
the test fails it refers to them as "reference" and "actual"
respectively. Just switch them around.