Yes, we are. I note that we are talking about
automated tests . This thing is just vital for a particularly functional (basic, low-level) code, which contains the framework Django itself. But why not apply tests for sites? And this is not just a “joke”, but some kind of protection against smut.
Often it is necessary to update Django and related applications on the server, which sometimes leads to problems that are highly undesirable on customer sites. And the main problem is 500 error, which will be an indicator of failure in the text below.
So, Django provides the
ability to write tests for applications, and this makes everything easier.
')
In most sites, nothing can collapse just like that, it is most likely due to backward incompatible changes in Django, or the impact of such changes on third-party applications (django-voting etc). Having written the simplest test that will check if the page returns a valid code (ie 200), we will determine the non-working pages at the first run of all tests, and accordingly the problem code.
So at the end of all of this is a short code (for the rest, see the
documentation ):
from django.test import TestCase
class LentaTest (TestCase):
def test_index (self):
response = self.client.get ('/ lenta /')
self.failUnlessEqual (response.status_code, 200)
The code is put in appname / tests.py, and to run the tests, we do the manage.py test appname