weird unittest result

Peter Hansen peter at engcorp.com
Wed Oct 1 14:11:46 EDT 2003


"Gonçalo Rodrigues" wrote:
> 
> I use the unittest module for testing a given module's functionality,
> by lumping several test classes and then at the end a simple
> 
> if __name__ == "__main__":
>     unittest.main()
> 
> In one of these, I get, at a DOS prompt the following weird result:
> 
> C:\Gonçalo\Programming\Python\Code\Library\Connection>c:\python23\python
> TestSocketstream.py
> ....Exception exceptions.AttributeError: "'Socket' object has no
> attribute '_Socket__socket'" in  ignored
> ..
> ----------------------------------------------------------------------
> Ran 6 tests in 0.040s
> 
> All tests passing and yet some AttributeError is raised somewhere.
> This is even more bizarre because the Socket object does have a
> private __socket attribute.
> 
> Anyone has an inkling of what might be going on?

The tests appear to be passing because something is catching the
exception and ignoring it.  The above exception is not a normal
exception message, so I think some code is printing that message
in an exception handler somewhere.

As for your comment about "even more bizarre", I think the whole
point of the message is that Socket doesn't have a __socket 
attribute, but clearly some code somewhere thinks it does and is
attempting to access it.

Would it help if I pointed out that the standard Python socket 
object is "socket" and not "Socket"?  Maybe you're getting confused
about what code is really being executed.

Sorry I can't help more.

-Peter




More information about the Python-list mailing list