12

I'm aware of how to run a specific test class with django : python manage.py test MyApp.MyTestClass.

What I'd like to do is the opposite : run every tests except one in particular. To my mind, this would look like this : python manage.py test --ignore=MyApp.MyTestClass Is there a simple way to do so ?

EDIT : An extra bonus would be to still be able to run the test manually (using the first command).

merours
  • 4,076
  • 7
  • 37
  • 69

2 Answers2

19

The test command has no built-in ignore option.

But you could use the @skip or @skipIf decorator in the class you want to exlude: http://docs.python.org/2.7/library/unittest.html#unittest.skipIf

 import unittest

 @unittest.skip("skip the test")
 class MyTestClass(TestCase):
 ...
shry
  • 1,872
  • 16
  • 9
  • I added an extra need wich is not easily satisfied with this solution (as far as I can tell). – merours Oct 02 '13 at 08:53
  • skip works on the class, but skipIf does not. You have to use skipIf on each test function. This is still a good way of conditionally skipping tests though. – MagicLAMP Mar 22 '18 at 12:49
4

Test command does not have ignore option by default. You can try django-ignoretests. You can install it using

pip install django-ignoretests

You can ignore apps by including them in IGNORE_TESTS as given below:

IGNORE_TESTS = (
    # Apps to ignore. example : 'django.contrib.auth',
)
arulmr
  • 8,620
  • 9
  • 54
  • 69