Unittest tests order

后端 未结 19 1257
刺人心
刺人心 2020-12-01 03:17

How do I be sure of the unittest methods order? Is the alphabetical or numeric prefixes the proper way?

class TestFoo(TestCase):
    def test_1(self):
               


        
相关标签:
19条回答
  • 2020-12-01 04:10

    Don't rely on the order. If they use some common state like the filesystem or database, then you should create setUp and tearDown methods that get your environment into a testable state, then clean up after the tests have run. Each test should assume that the environment is as defined in setUp, and should make no further assumptions.

    0 讨论(0)
提交回复
热议问题