Re: testing a website from python

2005-09-21 Thread Benji York
matt wrote:
 Here's something I did recently at work.  
 It contains unittest code and is using
 urllib2.
 http://blog.spikesource.com/pyhton_testcases.htm

If you want to test web sites, you might be interested in 
zope.testbrowser (currently Zope 3 only, but fixing that is on my to do 
list).

You can see an example testbrowser test (which is also both its README 
and its unit tests) at 
http://svn.zope.org/*checkout*/Zope3/branches/testbrowser-integration/src/zope/testbrowser/README.txt?rev=38050

If there is any interest I'll try to package up a stand-alone version in 
the next few days.
--
Benji York
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Achim Domma (SyynX Solutions GmbH)
Benji York wrote:

 If there is any interest I'll try to package up a stand-alone version in 
 the next few days.

I think that would be a very usefull tool. Currently I'm using httpunit 
with Jython but a python only tool would be much nicer.

regards,
Achim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Grig Gheorghiu
Achim,

Have you looked into twill? It's available at
http://www.python.org/pypi/twill/0.7.2

Grig

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Josef Meile
Hi,

 I just want to test that a given website is up or not from a python 
 script.  I thought of using wget as an os command.  Any better ideas?
Here is how I did it:

import urllib2
import socket
def checkUrl(url, timeout=1):
   Checks an url for a python version greater
  than 2.3.3.

  Note: For me isn't important the kind of
HTTP Error. If you want to know it,
then take a look at the existent
solutions like CMFLinkChecker and
see how they extract the code from
the error message.
   
   error={'code':1, 'msg':'Success'}
   defTimeOut=socket.getdefaulttimeout()
   socket.setdefaulttimeout(timeout)
   try:
 urllib2.urlopen(url)
   except (urllib2.HTTPError, urllib2.URLError,
   socket.error, socket.sslerror):
 error['code']=-2
 error['msg']=The link: \${link}\ couldn't be validated
   except:
 socket.setdefaulttimeout(defTimeOut)
 raise

   socket.setdefaulttimeout(defTimeOut)
   return error

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-21 Thread Benji York
Achim Domma (SyynX Solutions GmbH) wrote:
 Benji York wrote:
If there is any interest I'll try to package up a stand-alone version in 
the next few days.
 
 I think that would be a very usefull tool. Currently I'm using httpunit 
 with Jython but a python only tool would be much nicer.

I put a first cut at http://benjiyork.com/zope.testbrowser-0.1.tgz). 
See the README.txt for general info and over_the_wire.txt for how to use 
it to access web sites.  It requires the zope.interface package from 
http://www.zope.org/Products/ZopeInterface (version 3.0.1 should work).
--
Benji York

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-20 Thread Laszlo Zsolt Nagy
M.N.A.Smadi wrote:

hi;

I just want to test that a given website is up or not from a python 
script.  I thought of using wget as an os command.  Any better ideas?
  

urllib

http://www.python.org/doc/current/lib/module-urllib.html

If you only want to test if the HTTP port is open or not:

socket

http://docs.python.org/lib/module-socket.html

   Les

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: testing a website from python

2005-09-20 Thread matt
Here's something I did recently at work.  (Thought it's testing http
digest authentication, the idea would the same (testNoAuth() is
probably doing what you want)).  It contains unittest code and is using
urllib2.
http://blog.spikesource.com/pyhton_testcases.htm

matt

-- 
http://mail.python.org/mailman/listinfo/python-list