[TIP] HTTP servers testing
Kumar McMillan
kumar.mcmillan at gmail.com
Wed Feb 28 12:15:00 PST 2007
I just wrote titus off the list saying how psyched I am with
wsgi_intercept (after his champion presentation) but, heck, let me
just share with everyone this little adapter I am currently using on
top of wsgi_intercept. It was a shot in the dark but already seems to
at least conceal the details of installing a wsgi fixture, maybe not
an actual "standard"
In this example I'm using it in a test that needs a stub response sent
back from a rest service:
service = WSGIIntercept(install_for=['urllib2'])
def setup():
# set it to staging...
service.host = '192.168.x.x'
service.port = 8990
service.uri = "/theservice"
# here, an environ var will be checked
# to see if we want to be in "stub" mode.
# if so:
service.enable = True # now it will intercept
@service.sends_response("<pretend>this is xml</pretend>")
def test_transfer()
cmd = run_cmd(['--url', service.mkurl()])
# etc...
... the decorator does all the urllib2 installation and temporarily
intercepts only while this test is running.
> Or, as I now explain it, "wsgi_intercept lets Python Web testing
> packages talk directly to a WSGI app without running a server"...
>
> I'll post some examples soon.
>
> I think it would be nice to build a "Web fixtures" package (perhaps
> divorced from twill?) that would set up and run servers in a "standard"
> way. Then we could try to contribute this back to the individual
> projects & hope for incorporation.
>
> Standardizing fixtures == good, right??
>
> --titus
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
More information about the testing-in-python
mailing list