@unittest.skip_others decorator
Hello, 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) + support.run_unittest(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 == @unittest.exclude_others class TestCase1: ... All TestCase1 test cases are run, TestCase2, TestCase3 and TestCase4 classes are excluded. == use case #2 == class TestCase1: @unittest.exclude_others def test_something(self): .... All TestCase1.* tests are excluded except "test_something". TestCase2, TestCase3 and TestCase4 are run. == use case #3 == @unittest.exclude_others class TestCase1: @unittest.exclude_others def test_something(self): .... Only TestCase1.test_something() is run (this is the most common use case). Thoughts? Kindest regards, --- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/
Hi, you may be interested in this. It's part of the unittest module that ships with Python: ======================= ./python.exe -m unittest test.test_call.CFunctionCalls.test_varargs0 . ---------------------------------------------------------------------- Ran 1 test in 0.000s OK ======================= An added bonus is that this works across many Python projects. Hope this helps, Jerry Seutter On Mon, Aug 16, 2010 at 2:37 PM, Giampaolo Rodolà <g.rodola@gmail.com>wrote:
Hello, 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) + support.run_unittest(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 ==
@unittest.exclude_others class TestCase1: ...
All TestCase1 test cases are run, TestCase2, TestCase3 and TestCase4 classes are excluded.
== use case #2 ==
class TestCase1:
@unittest.exclude_others def test_something(self): ....
All TestCase1.* tests are excluded except "test_something". TestCase2, TestCase3 and TestCase4 are run.
== use case #3 ==
@unittest.exclude_others class TestCase1:
@unittest.exclude_others def test_something(self): .... Only TestCase1.test_something() is run (this is the most common use case).
Thoughts?
Kindest regards,
--- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ _______________________________________________ Python-ideas mailing list Python-ideas@python.org http://mail.python.org/mailman/listinfo/python-ideas
On 8/16/2010 4:37 PM, Giampaolo Rodolà wrote:
Hello, 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) + support.run_unittest(TestCase4)
...and then comment out all the test cases in TestCase4 class except the one I'm interested in.
How about using a special TestDevelopment with only the test cases you are working on? Then comment out the standard run and uncomment the development run # support.run_unittest(TestCase1, TestCase2, TestCase3, TestCase4) support.run_unittest(TestDevel) When done, move tests to whichever regular TestCase they belong in. -- Terry Jan Reedy
On Mon, 16 Aug 2010 22:37:07 +0200 Giampaolo Rodolà <g.rodola@gmail.com> wrote:
Hello, 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.
[...]
Thoughts?
This would certainly be useful to me as well. Regards Antoine.
On Wed, Aug 18, 2010 at 4:29 AM, Antoine Pitrou <solipsis@pitrou.net> wrote:
This would certainly be useful to me as well.
An alternative that would work for me is being able to specify particular test cases and methods to regrtest - currently it only offers test module granularity from the command line. Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia
participants (5)
-
Antoine Pitrou
-
Giampaolo Rodolà
-
Jerry Seutter
-
Nick Coghlan
-
Terry Reedy