diff options
| author | Aymeric Augustin | 2013-10-18 08:53:17 +0200 |
|---|---|---|
| committer | Aymeric Augustin | 2013-10-18 23:16:10 +0200 |
| commit | 8a591b86311c6c19c09b35e5fa3cba75f1d6be3e (patch) | |
| tree | b210f6d903ed3e08bb3436a482523c4a4c276ca6 /tests/tests.py | |
| parent | d112cc5ed14fa97eb187aa7f0b38318ea03d77dc (diff) | |
| download | django-debug-toolbar-8a591b86311c6c19c09b35e5fa3cba75f1d6be3e.tar.bz2 | |
Add test for issue #348.
Diffstat (limited to 'tests/tests.py')
| -rw-r--r-- | tests/tests.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/tests.py b/tests/tests.py index 2b26893..a08a9dd 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -9,7 +9,7 @@ from xml.etree import ElementTree as ET import django from django.conf import settings from django.contrib.auth.models import User -from django.db import connection +from django.db import connection, IntegrityError from django.http import HttpResponse from django.test import TestCase, RequestFactory from django.test.utils import override_settings @@ -188,6 +188,18 @@ class DebugToolbarIntegrationTestCase(TestCase): response = self.client.get('/regular/XML/') ET.fromstring(response.content) # shouldn't raise ParseError + def test_view_executed_once(self): + with self.settings(DEBUG=True, INTERNAL_IPS=['127.0.0.1'], + DEBUG_TOOLBAR_PANELS=['debug_toolbar.panels.profiling.ProfilingDebugPanel']): + self.assertEqual(User.objects.count(), 0) + + response = self.client.get('/new_user/') + self.assertContains(response, 'Profiling') + self.assertEqual(User.objects.count(), 1) + + with self.assertRaises(IntegrityError): + response = self.client.get('/new_user/') + self.assertEqual(User.objects.count(), 1) class DebugToolbarNameFromObjectTest(BaseTestCase): |
