Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Colorizing the output of Django tests

Tags:

django

Is there a way to colorize the Django test output? Basically a Red/Green factor for a pass or failing results?

I am on Mac OS X using Terminal.app.

like image 681
tdelam Avatar asked Oct 19 '11 01:10

tdelam


People also ask

How does Django test work?

With Django's test-execution framework and assorted utilities, you can simulate requests, insert test data, inspect your application's output and generally verify your code is doing what it should be doing. The preferred way to write tests in Django is using the unittest module built-in to the Python standard library.

How do I write unit tests in Django?

Writing tests Django's unit tests use a Python standard library module: unittest . This module defines tests using a class-based approach. When you run your tests, the default behavior of the test utility is to find all the test cases (that is, subclasses of unittest.

What should you test in Django?

As discussed above, we should test anything that is part of our design or that is defined by code that we have written, but not libraries/code that is already tested by Django or the Python development team. For example, consider the Author model below.


1 Answers

redgreenunittests is the most simple solution and it works great with python 3.x

Install it

pip install redgreenunittest

add the next line into settings.py

TEST_RUNNER = "redgreenunittest.django.runner.RedGreenDiscoverRunner"

and don't forget to enjoy :)

./manage test

like image 142
injaon Avatar answered Oct 20 '22 15:10

injaon