mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Consolidated some many_to_one tests.
This commit is contained in:
@@ -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()), [])
|
||||
|
||||
Reference in New Issue
Block a user