Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django. How to locate slow tests?

How to locate slow django tests? How to locate tests, on which test runner can 'stuck'? Do you know any good custom django test runners, that can provide more detailed information on test performance?

like image 591
Nikolay Fominyh Avatar asked Dec 20 '11 10:12

Nikolay Fominyh


People also ask

Why are Django tests so slow?

By default, Django creates a test database for each test run, which is destroyed at the end. This is a rather slow process, especially if you want to run just a few tests! The --keepdb option will not destroy and recreate the database locally on every run.

How do I skip a Django test?

Just trick it to always skip with the argument True : @skipIf(True, "I don't want to run this test yet") def test_something(): ... 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.

How do I run tests PY in Django?

Open /catalog/tests/test_models.py.from django. test import TestCase # Create your tests here. Often you will add a test class for each model/view/form you want to test, with individual methods for testing specific functionality.

What is self client in Django?

self. client , is the built-in Django test client. This isn't a real browser, and doesn't even make real requests. It just constructs a Django HttpRequest object and passes it through the request/response process - middleware, URL resolver, view, template - and returns whatever Django produces.


1 Answers

You can get Django to print the tests it's running with:

./manage.py test -v 3

This will print the name of the test, run it, then print "ok". So you can figure out which test is slow.

like image 148
user9876 Avatar answered Sep 22 '22 06:09

user9876