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