473,322 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

weird unittest result

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
3 1897
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Paul Moore | last post by:
One of the things I really dislike about Unittest (compared, say, to a number of adhoc testing tricks I've used in the past, and to Perl's "standard" testing framework) is that the...
1
by: paul koelle | last post by:
Hi, I try to use the "failUnlessRaises()" method from unittest.TestCase as follows: >>self.failUnlessRaises(IntegrityError, myObject.new(**stuff)) where IntegrityError is an Exception...
8
by: Remy Blank | last post by:
Hello unittest users, In a project I am working on, I have a series of tests that have to be run as root, and others as a normal user. One solution is to separate the tests into two different...
0
by: Remy Blank | last post by:
Ok, here we go. I added the possibility for tests using the unittest.py framework to be skipped. Basically, I added two methods to TestCase: TestCase.skip(msg): skips unconditionally...
1
by: James Jeffers | last post by:
I couldn't find any resource that addresses output from the unittest package in python 2.4.x. I can't beleive that there isn't an output formatter/test runner for the unittest package.. surely some...
5
by: paul kölle | last post by:
hi all, I noticed that setUp() and tearDown() is run before and after *earch* test* method in my TestCase subclasses. I'd like to run them *once* for each TestCase subclass. How do I do that. ...
4
by: Helge Stenstroem | last post by:
Say I have a function def f(filename): result = openFileAndProcessContents(filename) return result Can that function be unit tested without having a real file as input? Something along the...
0
by: Chris Fonnesbeck | last post by:
I have built the following unit test, observing the examples laid out in the python docs: class testMCMC(unittest.TestCase): def setUp(self): # Create an instance of the sampler...
0
by: =?ISO-8859-1?Q?Israel_Fern=E1ndez_Cabrera?= | last post by:
Hi I'm writing some code that automatically execute some registered unit test in a way to automate the process. A sample code follows to illustrate what I'm doing: <code requires="save as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.