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