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

SourceForge.net noreply at sourceforge.net
Sun Mar 11 18:42:50 CET 2007


Patches item #1671298, was opened at 2007-02-28 17:38
Message generated for change (Comment added) made by collinwinter
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: Collin Winter (collinwinter)
Date: 2007-03-11 13: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 16: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 20: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-06 01: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 19: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