[Patches] [ python-Patches-1671298 ] Refactor test_class to use unittest lib

SourceForge.net noreply at sourceforge.net
Thu Apr 19 08:17:23 CEST 2007


Patches item #1671298, was opened at 2007-02-28 14:38
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1671298&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tests
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Mike Verdone (jyzude)
Assigned to: Collin Winter (collinwinter)
Summary: Refactor test_class to use unittest lib

Initial Comment:
Refactored Lib/test/test_class.py to use unittest library instead of icky output comparison tests. Also have to delete output/test_class after adding this patch.

----------------------------------------------------------------------

>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-04-18 23:17

Message:
Logged In: YES 
user_id=33168
Originator: NO

There should be a test_main method otherwise this won't work when called
from regrtest.  

Have you tried to run this with regrtest -R :: ?  I think it will work,
but just wanted to be sure.

One thing that might be nice to add to this test is to verify the change
in the length of the callLst since assertLastCallWas() was called. 
Typically there should be only one method call from what I saw in the test.
 However, if we screw something up and there are two method calls, this
test could catch that.  It would be an enhancement (ie new feature) over
the existing test.

----------------------------------------------------------------------

Comment By: Jerry Seutter (jseutter)
Date: 2007-04-18 10:45

Message:
Logged In: YES 
user_id=1727609
Originator: NO

This patch looks good to me.

----------------------------------------------------------------------

Comment By: Mike Verdone (jyzude)
Date: 2007-03-19 15:23

Message:
Logged In: YES 
user_id=584997
Originator: YES

Hi Collin,

Sorry for the delay. Your tweaks look very good. I don't see any problems.

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-03-11 10:42

Message:
Logged In: YES 
user_id=1344176
Originator: NO

Mike, I've tweaked your refactoring some: strengthened the assertions in
testMixIntsAndLongs and testDel; code cleanup in testBadTypeReturned;
removed Jython-related code; reduced line lengths to < 80; changed a few
print statements to self.fail() calls. Look over the version I've uploaded
and tell me what you think.
File Added: test_class.py.diff

----------------------------------------------------------------------

Comment By: Mike Verdone (jyzude)
Date: 2007-03-07 13:07

Message:
Logged In: YES 
user_id=584997
Originator: YES

Removed unnecessary global statement in trackCall.

Anything else? :-)
File Added: test_class.patch

----------------------------------------------------------------------

Comment By: Georg Brandl (gbrandl)
Date: 2007-03-06 17:03

Message:
Logged In: YES 
user_id=849994
Originator: NO

Note that you don't need the global statement for callLst as you aren't
rebinding it in the function.

----------------------------------------------------------------------

Comment By: Mike Verdone (jyzude)
Date: 2007-03-05 22:38

Message:
Logged In: YES 
user_id=584997
Originator: YES

Hi collin,

* I improved testMixIntsAndLongs. It now asserts things
* assert is banished, replaced by the correct calls
* the reason why callLst is global is because I have to track calls to
__getitem__ in some cases. Because of this, if I put callLst on the object
I end up with horrible recursive loops, or at the very least the last call
on the stack will always be __getitem__ when I get the list to inspect.
* assertLastCall only checks the last thing on the list because generally
the thing called before that is always __getitem__ or associated magic. I
don't want my tests to be bound to the  internals of __getitem__. All I
care about is that ultimately the right function was called. That said, I
modified assertLastCallWas to erase the callLst to prevent any possible
bleed-over from the previous test.

Let me know if you have further suggestions.
File Added: test_class.patch

----------------------------------------------------------------------

Comment By: Collin Winter (collinwinter)
Date: 2007-03-05 16:11

Message:
Logged In: YES 
user_id=1344176
Originator: NO

Thanks for your effort!

This generally looks good. A few minor things:

- testMixIntsAndLongs doesn't have any assertions in it.
- "assert" statements should probably be changed to use the
failUnlessEqual/assertEqual methods.
- I'm wary of your assertLastCallWas system; I'd feel more comfortable if
you were making assertions about the entire call chain, not just its last
item. Also, something like callLst feels strange as a global. Feel free to
contact me to discuss this off-list.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1671298&group_id=5470


More information about the Patches mailing list