[Python-Dev] Proposed unittest changes
jml at mumak.net
Fri Apr 18 00:28:17 CEST 2008
On Fri, Apr 18, 2008 at 12:54 AM, Guido van Rossum <guido at python.org> wrote:
> I'm worried that a mass renaming would do anything but inconvenience
> users during the already stressful 2->3 transition.
> I'm more in favor of the original proposal of reducing the redundancy post-3.0.
> If you're looking for useful features, Google has a set of extensions
> to unittest.py that I find useful:
> - module-level setUp and tearDown
> - routines for comparing large lists and strings that produce useful
> output indicating exactly where the inputs differ.
> - assertLess etc.
> - assertSameElements (sort of like assert(set(x) == set(y))
Some things that Bazaar, Twisted and Launchpad have found helpful:
- assertRaises returning the exception object that it catches. This
allows for easy testing of exception strings.
- Assertion methods for 'in', 'is' and 'isinstance' and their negations.
- TestCase.addCleanup. This method takes a function, args and kwargs
and pushes them to a stack of cleanups. Before tearDown is run, each
of these cleanups is popped off the stack and then run. This makes it
easier to acquire certain resources in tests:
dir = tempfile.mkdtemp()
Luckily, I have patches (with tests!) for these that I will be filing
on the tracker as soon as I get the opportunity.
More information about the Python-Dev