How can I make it so unit tests in Python (using unittest) are run in the order in which they are specified in the file?
How can I make it so unit tests in Python (using unittest ) are
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can change the default sorting behavior by setting a custom comparison function. In unittest.py you can find the class variable
unittest.TestLoader.sortTestMethodsUsingwhich is set to the builtin functioncmpby default.For example you can revert the execution order of your tests with doing this: