Steve, this looks really cool. If you send me a tar ball I will upload it
to the anon FTP area for Webware so that everyone can get it at their
leisure without bugging you.
At 05:49 PM 1/8/2001 +0100, Steve Purcell wrote:
>Hi Chuck, Jay and others,
>I noticed on the 'future plans' page that future testing of webkit might be
>based on PyUnit. As the author of that package, I thought I'd let you know
>that I've recently had some success doing automated web testing using PyUnit,
>the standard library module 'httplib' and some other code that I hacked up.
>Basically, I ended up with a module 'httpsession' that deals transparently
>with redirections and cookies, and allows testing assertions to be made on
>things like response code and page contents.
>For example, I can test the login part of the java servlet system I'm writing
>using code similar to that below:
> class LoginTestCase(unittest.TestCase):
> def testLoginRequired(self):
> session = httpsession.HTTPSession("http://localhost:1234")
> ## Ask for front page; we should get redirected to login
> session.get("/", redirectsAllowed=2)
> ## Check that no errors occurred...
> assert session.replycode == 200
> ## ... and that we ended up on the login page
> assert session.path == self.LOGIN_PAGE
> ## Make sure the redirect param was set correctly
> assert session.query['redirect'] == self.MENU_PAGE
> page = session.getfile().read()
> ## Correct page contents?
> assert string.find(page, "Enter login") != -1
>Then I can run my collection of such tests using PyUnit on the command-line
>or in the GUI. It works quite well for me, but it's early days yet.
>If anyone is interested, I can send the [quite rough] 'httpsession' source
>to them. I'm keen to get feedback because I am considering setting up a
>separate SourceForge project specialising in such testing using Python; I want
>to know if I'm on the right track.
>Please CC any replies to me because I am not subscribed to the list.
>Best wishes to all,
>Steve Purcell, Pythangelist
>Get testing at http://pyunit.sourceforge.net/
>Available for consulting and training.
>"Even snakes are afraid of snakes." -- Steven Wright
>Webware-discuss mailing list