[TIP] alphabetical order in testing

Alfredo Deza alfredodeza at gmail.com
Tue Jan 19 12:26:26 PST 2010


Hi

I am aware that test methods are executed in alphabetical order.

What would be the ideal/preferable way of dealing with methods that depend
in the order they are being executed?

Given that:

class TestFiles(unittest.TestCase):
>
>     def test_second_file(self):
>         """I depend on z_file"""
>
>     def test_z_file(self):
>         """I should run before second_file"""
>


Would it be OK to alter the naming in the methods to make sure they are run
in the order I need to? Even if the naming gets really weird like:

def test_a_z_file(self)
>

Or is there a different/better way to do this? I am thinking something like
breaking the above example in 2 different classes and creating the setUp()
and tearDown() methods for each, but wouldn't that be a little redundant?

Thanks again for the help!


-- 
Alfredo Deza
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100119/11b181a2/attachment.htm>


More information about the testing-in-python mailing list