I have a bunch of unit tests in a file using the unittest format. When i right click on the file in the left pane of pycharm i see the option to "Run Unittests in test_filename,py". That runs all the unit tests and im a happy camper. The device im testing however, sometimes needs some of the unit tests to be run before others. Before the inevitable "you shouldn't do that", "you're a moron" comments i was hoping to get some help. The unittest.TestLoader class has a property called sortTestMethodsUsing. If that is set to None then the test loader will load up the tests in the order it finds them in the unittest.TestCase class containing all the unit tests in the test_filename.py script. You can also set that property to whatever sort order you want. Its quite useful.
I understand the right click > "Run 'Unittests in test_filename.py'" operation uses unittest.TestLoader in the background to load up all the tests to execute. Is there any way to set the sortTestMethodsUsing property of the TestLoader pycharm is using? Ideally i'd like to default it to None for all the unit tests i run.
At this point my 2 options i can see are:
1) name the unit test functions under my unittest.TestCase class to be something like test_0010_function_name, test_0020_function_name2...etc. It works but is a pain.
2) create another script that instantiates a TestLoader allowing me to set the sortTestMethodsUsing property to whatever i want. Then run the test suite the loader returns. But then i wont be able to use the right click run option in pycharm which is incredibly convenient. And ill have to create one of these scripts for each of my unittest files.
Thanks for your time,