[Python-Dev] setUpClass and setUpModule in unittest (original) (raw)
Olemis Lang olemis at gmail.com
Tue Feb 9 19:29:04 CET 2010
- Previous message: [Python-Dev] setUpClass and setUpModule in unittest
- Next message: [Python-Dev] setUpClass and setUpModule in unittest
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Feb 9, 2010 at 11:42 AM, Michael Foord <fuzzyman at voidspace.org.uk> wrote:
Hello all,
Several authors of other Python testing frameworks spoke up against them, but several users of test frameworks spoke up in favour of them. ;-)
+1 for having something like that included in unittest
I'm pretty sure I can introduce setUpClass and setUpModule without breaking compatibility with existing unittest extensions or backwards compatibility issues
Is it possible to use the names BeforeClass
and AfterClass
(just
to be make it look similar to JUnit naming conventions ;o) ?
- with the possible exception of test sorting. Where you have a class level setUp (for example creating a database connection) you don't want the tearDown executed a long time after the setUp. In the presence of class or module level setUp /tearDown (but only if they are used) I would expect test sorting to only sort within the class or module [1]. I will introduce the setUp and tearDown as new 'tests' - so failures are reported separately,
Perhaps I am missing something, but could you please mention what will
happen if a failure is raised inside class-level tearDown
?
and all tests in the class / module will have an explicit skip in the event of a setUp failure.
+1
A better (more general) solution for sharing and managing resources between tests is to use something like TestResources by Robert Collins. http://pypi.python.org/pypi/testresources/
A minimal example of using test resources shows very little boilerplate overhead from what setUpClass (etc) would need, and with the addition of some helper functions could be almost no overhead. I've challenged Robert that if he can provide examples of using Test Resources to meet the class and module level use-cases then I would support bringing Test Resources into the standard library as part of unittest (modulo licensing issues which he is happy to work on).
I am not really sure about whether unittest API should grow, and grow, and grow, and ... but if that means that TestResources will not be even imported if testers don't do it explicitly in the code (which is not the case of something like class level setUp/tearDown) then +1, otherwise -0.5
-- Regards,
Olemis.
Blog ES: http://simelo-es.blogspot.com/ Blog EN: http://simelo-en.blogspot.com/
Featured article:
TracGViz plugin downloaded more than 1000 times (> 300 from PyPI) -
http://feedproxy.google.com/r/simelo-en/3/06Exn-JPLIA/tracgviz-plugin-downloaded-more-than.html
- Previous message: [Python-Dev] setUpClass and setUpModule in unittest
- Next message: [Python-Dev] setUpClass and setUpModule in unittest
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]