Issue 2153: unittest.py modernization - Python tracker (original) (raw)

Created on 2008-02-21 13:18 by vdupras, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unittest_modern.diff vdupras,2008-02-21 13:18
unittest_modern2.diff vdupras,2008-08-08 11:01
Messages (9)
msg62622 - (view) Author: Virgil Dupras (vdupras) (Python triager) 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) * (Python committer) Date: 2008-02-21 16:29
À propos modernizing unittest, may I suggest taking a look at #1034053. :)
msg62641 - (view) Author: Steve Purcell (purcell) (Python triager) 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) (Python triager) 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) (Python triager) 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) * (Python committer) 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) (Python triager) 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) * (Python committer) Date: 2008-12-28 15:36
Will take a look.
msg78415 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-12-28 16:01
Committed in r67985, thanks!
History
Date User Action Args
2022-04-11 14:56:31 admin set github: 46406
2008-12-28 16:01:49 pitrou set status: open -> closedresolution: fixedmessages: +
2008-12-28 15:36:17 pitrou set messages: + versions: + Python 2.7, - Python 2.6
2008-08-08 11:01:26 vdupras set files: + unittest_modern2.diffmessages: +
2008-02-21 20:05:28 christian.heimes set priority: normalkeywords: + patch
2008-02-21 20:05:15 christian.heimes set nosy: + christian.heimesmessages: +
2008-02-21 19:55:14 purcell set messages: +
2008-02-21 19:43:24 vdupras set messages: +
2008-02-21 19:27:43 purcell set messages: +
2008-02-21 17:41:33 benjamin.peterson set nosy: + purcell
2008-02-21 16:29:57 pitrou set nosy: + pitroumessages: +
2008-02-21 13🔞13 vdupras create