Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does django-nose differ from the default Django test-runner

I've been seeing and reading about a lot of people using nose to run their Django tests. I haven't been able to figure out the added benefits of using Nose to run my Django tests. If someone could fill me in on what nose is and how it adds more to a Django project, it would be helpful.

I haven't been able to find a good document/article outlining these points.

Thank you

like image 556
Mridang Agarwalla Avatar asked Oct 21 '11 07:10

Mridang Agarwalla


People also ask

What is RequestFactory in Django?

The request factory class RequestFactory. The RequestFactory shares the same API as the test client. However, instead of behaving like a browser, the RequestFactory provides a way to generate a request instance that can be used as the first argument to any view.

How do I test coverage in Django?

With Django's Test Runner. If you're using manage.py test , you need to change the way you run it. You need to wrap it with three coverage commands like so: $ coverage erase # Remove any coverage data from previous runs $ coverage run manage.py test # Run the full test suite Creating test database for alias 'default'.. ...

What is Django test client?

The test client is a Python class that acts as a dummy web browser, allowing you to test your views and interact with your Django-powered application programmatically.


2 Answers

I was curious about this too and it seems that the main advantage of django-nose using the python nose library is "Test Discovery".

In addition, from http://readthedocs.org/docs/nose/en/latest/testing.html

you can also write simple test functions, as well as test classes that are not subclasses of unittest.TestCase. nose also supplies a number of helpful functions for writing timed tests, testing for exceptions, and other common use cases. See Writing tests and Testing tools for more.

From what I understand from other python developers on freenode irc, Trial test runner on Twisted Framework have these similar features like nose.

I am still not entirely convinced about using django-nose for django development but am giving a shot and report back if I find out more!

like image 111
Calvin Cheng Avatar answered Oct 12 '22 21:10

Calvin Cheng


There are a lot more features overall, but I think one major reason people use nose/djano_nose is that it allows you to very easily do code coverage.

python manage.py test myapp --with-coverage --cover-package=myapp
like image 30
Evan R. Avatar answered Oct 12 '22 20:10

Evan R.