[TIP] setUp and tearDown behavior
Olemis Lang
olemis at gmail.com
Tue Jan 19 06:53:03 PST 2010
On Tue, Jan 19, 2010 at 9:32 AM, John Arbash Meinel
<john at arbash-meinel.com> wrote:
> Michael Foord wrote:
>> On 19/01/2010 13:53, Olemis Lang wrote:
>>> [snip...]
>>>> In case this is expected, is there a way to do it just once for all the
>>>> methods?
>>>>
>>>>
>>> Using standard `unittest` module ? well ... no.
>>>
>>>
>> Well - you can make setup *effectively* only run the first time using a
>> class attribute:
>>
[...]
>
> I believe we handle it using "startTestRun()" and "stopTestRun()" but
> those are defined for the whole test suite, not for a subset.
>
-1
> A different possibility with the "test_suite()" or "load_tests()"
> paradigm, is that you can create a custom TestSuite instance that
> overloads run() (I believe) to do something like:
>
> class MySuite(unittest.TestSuite):
>
> def run(self):
> self.doSuiteSetup()
> unittest.TestSuite.run(self)
> self.doSuiteTearDown()
> ...
>
+1 , something like what I mentioned before (/we shooting almost at
the same time ;o) and implemented before [1]_
I just wanted to say that «the "test_suite()" or "load_tests()"
paradigm» are not needed to do that. Can be done using a custom test
loader ;o)
.. [1] dutest.DocTestSuiteFixture class @ SF.net
(http://flioops.hg.sourceforge.net/hgweb/flioops/dutest/file/0b5edb8a1e26/utils/dutest.py)
--
Regards,
Olemis.
Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/
Featured article:
Now `dutest` 1.2.3 is easy_install-able o -
http://flioops.hg.sourceforge.net/hgweb/flioops/dutest/rev/0b5edb8a1e26
More information about the testing-in-python
mailing list