By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,682 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,682 IT Pros & Developers. It's quick & easy.

weird unittest result

P: n/a
Hi,

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\Connect ion>c:\python23\python
TestSocketstream.py
.....Exception exceptions.AttributeError: "'Socket' object has no
attribute '_Socket__socket'" in ignored
...
----------------------------------------------------------------------
Ran 6 tests in 0.040s

OK

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?

With my best regards,
G. Rodrigues
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Gonçalo Rodrigues <op*****@mail.telepac.pt> writes:
[...]
....Exception exceptions.AttributeError: "'Socket' object has no
attribute '_Socket__socket'" in ignored [...] All tests passing and yet some AttributeError is raised somewhere.
The exception message seems to have been damaged in the cut-n-paste.
Could it be that an exception was thrown in a __del__ method?

Plenty of threads in Google Groups about this, if you want to know
more (exception ignored group:comp.lang.python).

This is even more bizarre because the Socket object does have a
private __socket attribute.


Not if it has already been deleted, I guess.
John
Jul 18 '05 #2

P: n/a
"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\Connect ion>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
Jul 18 '05 #3

P: n/a
On 01 Oct 2003 18:29:21 +0100, jj*@pobox.com (John J. Lee) wrote:
Gonçalo Rodrigues <op*****@mail.telepac.pt> writes:
[...]
....Exception exceptions.AttributeError: "'Socket' object has no
attribute '_Socket__socket'" in ignored

[...]
All tests passing and yet some AttributeError is raised somewhere.


The exception message seems to have been damaged in the cut-n-paste.
Could it be that an exception was thrown in a __del__ method?


Thanks! I've been able to track the problem and it's precisely in a
subtle interplay between a test testing that a certain exception is
raised (which implies that the __init__ method is not completed) and
the __del__ method.

Simplest solution: delete __del__, it's not needed anywhere.

With my best regards,
G. Rodrigues
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.