Hi, you may be interested in this. It's part of the unittest module that ships with Python:
when working on a test suite, no matter if writing new test cases from
scratch or modifying an existing one, the need of temporarily
excluding other tests and focus on that particular one is very common
(at least for me).
This is especially true when working on a test suite which contains a
lot of tests producing a very verbose output result or which takes a
lot to complete.
What I usually do in such cases is to scroll down until test_main()
function, manually change support.run_unittest() ilke this:
- support.run_unittest(TestCase1, TestCase2, TestCase3, TestCase4)
...and then comment out all the test cases in TestCase4 class except
the one I'm interested in.
This is obviously not very flexible, then I thought that maybe
unittest (or test/support module, I'm not sure) could provide a
specific decorator for temporarily running only one specific test
class(es) or method(s).
The decorator could be used in 3 ways:
== use case #1 ==
All TestCase1 test cases are run, TestCase2, TestCase3 and TestCase4
classes are excluded.
== use case #2 ==
All TestCase1.* tests are excluded except "test_something".
TestCase2, TestCase3 and TestCase4 are run.
== use case #3 ==
Only TestCase1.test_something() is run (this is the most common use case).
Python-ideas mailing list