Running a subset of automatically open python unittests

Short question
Is it possible at run time to choose which unittests will be run when using the automatic detection method in the Python unittest module.

Background
I use the unittest module to run system tests on an external system. The following is an example of sudo-testcase. The unittest module allows me to create arbitrary numerical testers that I can run using the unittest testrunner. I use this method for about 6 months of constant use, and it works very well.

At the moment I want to try to make it more universal and user friendly. For all of my test suites that I'm running now, I hard-coded which tests should be run for each system. This is normal for an unverified system, but when the test fails (the user connects to the wrong test point, etc.), he must restart the entire test suite. Since some of the suites may take up to 20 minutes, this is not ideal.

I know that you can create your own testuite constructors that could determine which tests should be run. My problem is that there are hundreds of test boxes that you can run, and keeping this will be a nightmare if the names of the test cases change, etc.

My hope was to use nose or the built-in unittest for this. Part of the discovery seems pretty straightforward for both options, but my problem is that the only way to select a subset of test patterns to run is to define a pattern that exists in the name of the test system. This means that I still have to hardcode the list of templates to determine which test scripts will run. So if I need to hard code this list, what is the point of using automatic detection (note that this is a rhetorical question)?

, , unittests , , . Python 2.7, Windows, OSX Linux.

Edit
, , . , , Suite ( ), . , , testuite " " .

Testcase

test_measure_5v_reference 
    1) Connect to DC power supply via GPIB
    2) Set DC voltage to 12.0 V
    3) Connect to a Digital Multimeter via GPIB
    4) Measure / Record the voltage at a given 5V reference test point
    5) Use unittest assert functions to make sure the value is within tolerance
+5
1

. , , , , . , , , - .

testsuite = unittest.TestSuite()
for module in modules:
  testsuite.addTest(unittest.defaultTestLoader.loadTestsFromModule(module))
+1

All Articles