From 2c51defccf9d949430273c5dd81a99154071ec5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Sun, 22 Sep 2013 21:05:23 +0300 Subject: [PATCH] Fixed a couple of failing test cases --- tests/expressions/tests.py | 12 +++++++----- tests/force_insert_update/tests.py | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 9801d0acbbfd5..a960f87587b8a 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals from django.core.exceptions import FieldError +from django.db import transaction from django.db.models import F from django.test import TestCase from django.utils import six @@ -185,11 +186,12 @@ def test_filter(self): "foo", ) - self.assertRaises(FieldError, - lambda: Company.objects.exclude( - ceo__firstname=F('point_of_contact__firstname') - ).update(name=F('point_of_contact__lastname')) - ) + with transaction.atomic(): + self.assertRaises(FieldError, + lambda: Company.objects.exclude( + ceo__firstname=F('point_of_contact__firstname') + ).update(name=F('point_of_contact__lastname')) + ) # F expressions can be used to update attributes on single objects test_gmbh = Company.objects.get(name="Test GmbH") diff --git a/tests/force_insert_update/tests.py b/tests/force_insert_update/tests.py index 706a099872f1f..d3cafea81ebdb 100644 --- a/tests/force_insert_update/tests.py +++ b/tests/force_insert_update/tests.py @@ -26,7 +26,8 @@ def test_force_update(self): # Try to update something that doesn't have a primary key in the first # place. c1 = Counter(name="two", value=2) - self.assertRaises(ValueError, c1.save, force_update=True) + with transaction.atomic(): + self.assertRaises(ValueError, c1.save, force_update=True) c1.save(force_insert=True) # Won't work because we can't insert a pk of the same value.