Skip to content

Commit

Permalink
Fixed a couple of failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
akaariai committed Sep 22, 2013
1 parent 2df5618 commit 2c51def
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 7 additions & 5 deletions 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
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion tests/force_insert_update/tests.py
Expand Up @@ -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.
Expand Down

0 comments on commit 2c51def

Please sign in to comment.