Skip to content

Instantly share code, notes, and snippets.

@loic
Created June 3, 2014 05:02
Show Gist options
  • Save loic/848cfb5cf8d139a432b3 to your computer and use it in GitHub Desktop.
Save loic/848cfb5cf8d139a432b3 to your computer and use it in GitHub Desktop.
diff --git a/tests/one_to_one/models.py b/tests/one_to_one/models.py
index b54cabb..684e4f8 100644
--- a/tests/one_to_one/models.py
+++ b/tests/one_to_one/models.py
@@ -29,6 +29,8 @@ class Restaurant(models.Model):
def __str__(self):
return "%s the restaurant" % self.place.name
+class Bar(models.Model):
+ place = models.OneToOneField(Place, null=True)
@python_2_unicode_compatible
class Waiter(models.Model):
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index b42666a..ff6b127 100644
--- a/tests/one_to_one/tests.py
+++ b/tests/one_to_one/tests.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import transaction, IntegrityError
from django.test import TestCase
-from .models import (Place, Restaurant, Waiter, ManualPrimaryKey, RelatedModel,
+from .models import (Place, Restaurant, Bar, Waiter, ManualPrimaryKey, RelatedModel,
MultiModel)
@@ -133,4 +133,9 @@ class OneToOneTests(TestCase):
# Refs. 10811
place = Place(name='User', address='London')
with self.assertRaises(ValueError):
- r = Restaurant.objects.create(place=place, serves_hot_dogs=True, serves_pizza=False)
+ Restaurant.objects.create(place=place, serves_hot_dogs=True, serves_pizza=False)
+ bar = Bar()
+ with self.assertRaises(ValueError):
+ p = Place(name='User', address='London')
+ p.bar = bar
+ p.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment