Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore a specific test using Django [duplicate]

Tags:

python

django

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).

like image 989
merours Avatar asked Oct 02 '13 08:10

merours


2 Answers

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):
 ...
like image 78
shry Avatar answered Nov 12 '22 05:11

shry


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',
)
like image 33
arulmr Avatar answered Nov 12 '22 03:11

arulmr