Consolidated some many_to_one tests.

This commit is contained in:
Loic Bistuer 2014-09-23 23:29:17 +07:00
parent 2a1bdf5ced
commit 1fd6e13bf2
10 changed files with 244 additions and 276 deletions

View file

@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.test import TestCase
from .models import Reporter, Article
from .models import Article, Car, Driver, Reporter
class ManyToOneNullTests(TestCase):
@ -105,3 +105,10 @@ class ManyToOneNullTests(TestCase):
with self.assertNumQueries(1):
r.article_set.clear()
self.assertEqual(r.article_set.count(), 0)
def test_related_null_to_field(self):
c1 = Car.objects.create()
d1 = Driver.objects.create()
self.assertIs(d1.car, None)
with self.assertNumQueries(0):
self.assertEqual(list(c1.drivers.all()), [])