[Zope-dev] Adding W3C validating to zope.testbrowser

Ross Patterson me at rpatterson.net
Sun Feb 28 09:03:56 EST 2010


Brian Sutherland <brian at vanguardistas.net> writes:

> On Tue, Feb 23, 2010 at 04:57:02PM +0200, Marius Gedminas wrote:
>> On Tue, Feb 23, 2010 at 08:57:09AM -0500, Benji York wrote:
>> > On Sat, Feb 20, 2010 at 7:53 AM, Ross Patterson <me at rpatterson.net> wrote:
>> > > I started a branch for doing W3C HTML validation on responses to
>> > > zope.testbrowser requests:
>> > >
>
>> > > svn://svn.zope.org/repos/main/zope.testbrowser/branches/rossp-validator
>> > >
>> > > The idea is to be able to flip a switch and run all my functional
>> > > zope.testbrowser tests and see validation failures as test failures.
>> > 
>> > I'm not keen on this idea.  Validation checking isn't hard to do with
>> > testbrowser as-is, and doing it on every page load is overkill.  Add to
>> > that the global nature of the required switch and this really doesn't
>> > seem like the right approach.
>> 
>> I'd like to chime in and suggest using WSGI to hook up zope.testbrowser
>> and zope.app.testing.functional (or a better-designed replacement for
>> the latter).  Then you could plug in W3CValidatingMiddleware (if one
>> doesn't exist, it should be trivial to write it) between them.
>
> We use wsgi_intercept to get zope.testbrowser to listen to the other end
> of a WSGI pipe during testing
>
>     http://pypi.python.org/pypi/wsgi_intercept

Yeah, I've looked at wsgi_intercept before.  Good stuff.

> The testbrowser integration we have is far from perfect but was enough
> for is to stop using zope.app.testing.functional
>
>     http://svn.zope.org/van.testing/trunk/van/testing/layer.py?rev=105324&view=markup

Thanks, I'll check it out.

> It would be pretty simple to have a make_application call that wrapped
> the application in validating middleware depending on an environment
> variable.

Yeah, the more I've thought about it, the more I've been thinking the
right place to do this is in the application's publisher somehow, such
as in a WSGI pipeline.  This would make the validation more widely
usable, specifically to non-developers.  It would me more of a kind of
debug mode.

Lo and behold, it's been done:

http://workaround.org/node/266

Appending the validation errors to the end of the page won't work for
using existing functional tests as a validation testbed because no error is
raised on validation failures and many functional tests ignore the
parts of the returned page they're not interested in.  As such, the
tests won't fail on validation errors.  I can't imagine it would be too
hard to change this behavior.

I'll have to try adding WSGI to one of my typical Zope 2.10, Plone 3
add-on testing buildouts to see how much of a burden this places.

More later,
Ross



More information about the Zope-Dev mailing list