diff options
| author | Aymeric Augustin | 2013-10-26 13:51:47 +0200 | 
|---|---|---|
| committer | Aymeric Augustin | 2013-10-26 13:51:47 +0200 | 
| commit | 3a5492b471d907bdb66c627914264ee1f2d4e537 (patch) | |
| tree | fb06f1f1eb7c52d0c11fe9235f5c31cb16fc54c4 /tests | |
| parent | 4a340632a094e675ffaa61a3e85b43fa539bf0cf (diff) | |
| download | django-debug-toolbar-3a5492b471d907bdb66c627914264ee1f2d4e537.tar.bz2 | |
Fix tests under Django 1.6.
Fix #425.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/tests.py | 10 | 
1 files changed, 7 insertions, 3 deletions
| diff --git a/tests/tests.py b/tests/tests.py index c98319b..3c28f79 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -11,7 +11,7 @@ import django  from django.conf import settings  from django.contrib.auth.models import User  from django.core import management -from django.db import connection, IntegrityError +from django.db import connection, IntegrityError, transaction  from django.db.backends import util  from django.http import HttpResponse  from django.test import TestCase, RequestFactory @@ -197,7 +197,11 @@ class DebugToolbarIntegrationTestCase(TestCase):              self.assertEqual(User.objects.count(), 1)              with self.assertRaises(IntegrityError): -                response = self.client.get('/new_user/') +                if hasattr(transaction, 'atomic'):      # Django >= 1.6 +                    with transaction.atomic(): +                        response = self.client.get('/new_user/') +                else: +                    response = self.client.get('/new_user/')              self.assertEqual(User.objects.count(), 1)  class DebugToolbarNameFromObjectTest(BaseTestCase): @@ -366,6 +370,6 @@ class DebugSQLShellTestCase(TestCase):          original_stdout, sys.stdout = sys.stdout, six.StringIO()          try:              User.objects.count() -            self.assertIn("SELECT COUNT(*)\n", sys.stdout.getvalue()) +            self.assertIn("SELECT COUNT(*)", sys.stdout.getvalue())          finally:              sys.stdout = original_stdout | 
