msg62622 - (view) |
Author: Virgil Dupras (vdupras)  |
Date: 2008-02-21 13:18 |
What prompted me to do these changes is that "Backward compatibility" section for 2.1 and earlier. How long are we going to keep this? According to svn, no commit has been made on the 2.1 branch since 2003. Is it safe to assume no unittest change is ever going to be backported to 2.1? Then, while I was in it, I made other changes: - dict.has_key(key) --> key in dict - raise Exception, args --> raise Exception(args) - try..except KeyboardInterrupt: raise except: do_stuff() --> try..except Exception: do_stuff() - __metaclass__ = type --> all classes are now object subclasses I'm not sure about the last one. Are those 2 equivalent? Is there a reason to keep is as "__metaclass__ = type"? regrtest passed for me. |
|
|
msg62628 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2008-02-21 16:29 |
À propos modernizing unittest, may I suggest taking a look at #1034053. :) |
|
|
msg62641 - (view) |
Author: Steve Purcell (purcell)  |
Date: 2008-02-21 19:27 |
Hi Virgil; thanks for stepping up to this. Backward compatibility was largely for the sake of compatibility with Jython, which was always lagging far behind CPython. I doubt it's a concern these days, and the unittest.py in the Python source repository should probably always be implemented in the nicest, cleanest way possible with the latest CPython. Your changes look good to me, except for the KeyboardInterrupt one -- unless the way Ctrl-C is handled by Python has changed in the last couple of years, changing this "except:" clause will stop the text-mode test runner from being interruptible. Admittedly the TextTestRunner should somehow be given an opportunity to detect Ctrl-C in order to stop when asked, but this diff does not allow for that. |
|
|
msg62642 - (view) |
Author: Virgil Dupras (vdupras)  |
Date: 2008-02-21 19:43 |
Isn't it why KeyboardInterrupt is a subclass of BaseException instead of Exception (along with SystemExit)? so that "except Exception:" doesn't catch it? |
|
|
msg62645 - (view) |
Author: Steve Purcell (purcell)  |
Date: 2008-02-21 19:55 |
Yes indeed - you're exactly right; just checked now. Then disregard my previous comment! |
|
|
msg62651 - (view) |
Author: Christian Heimes (christian.heimes) *  |
Date: 2008-02-21 20:05 |
All changes are looking fine to me but I haven't looked at the patch so far. "__metaclass__ = type" is easier to write than subclassing from object. Both are equivalent. >>> __metaclass__ = type >>> class Foo: pass ... >>> Foo <class '__main__.Foo'> >>> Foo.__bases__ (<type 'object'>,) >>> type(Foo) <type 'type'> |
|
|
msg70900 - (view) |
Author: Virgil Dupras (vdupras)  |
Date: 2008-08-08 11:01 |
This patch has gone invalid due to some recent conflicting changes. I remade it and I'm resubmitting it hoping that it will get applied. |
|
|
msg78410 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2008-12-28 15:36 |
Will take a look. |
|
|
msg78415 - (view) |
Author: Antoine Pitrou (pitrou) *  |
Date: 2008-12-28 16:01 |
Committed in r67985, thanks! |
|
|