Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you skip a unit test in Django?

How do forcibly skip a unit test in Django?

@skipif and @skipunless is all I found, but I just want to skip a test right now for debugging purposes while I get a few things straightened out.

like image 750
user798719 Avatar asked Jul 08 '13 05:07

user798719


People also ask

Are unit tests always necessary?

Unit tests are also especially useful when it comes to refactoring or re-writing a piece a code. If you have good unit tests coverage, you can refactor with confidence. Without unit tests, it is often hard to ensure the you didn't break anything.


1 Answers

Python's unittest module has a few decorators:

There is plain old @skip:

from unittest import skip  @skip("Don't want to test") def test_something():     ... 

If you can't use @skip for some reason, @skipIf should work. Just trick it to always skip with the argument True:

@skipIf(True, "I don't want to run this test yet") def test_something():     ... 

unittest docs

Docs on skipping tests

If you are looking to simply not run certain test files, the best way is probably to use fab or other tool and run particular tests.

like image 98
Ray Toal Avatar answered Oct 02 '22 11:10

Ray Toal