From 3a5492b471d907bdb66c627914264ee1f2d4e537 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Sat, 26 Oct 2013 13:51:47 +0200 Subject: Fix tests under Django 1.6. Fix #425. --- tests/tests.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3