mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Consolidated some many_to_one tests.
This commit is contained in:
parent
2a1bdf5ced
commit
1fd6e13bf2
10 changed files with 244 additions and 276 deletions
|
@ -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()), [])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue