summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/basic/models.py11
-rw-r--r--tests/regressiontests/datastructures/tests.py2
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index 2f4b932fe0..557331a36e 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -5,6 +5,11 @@
This is a basic model with only two non-primary-key fields.
"""
+try:
+ set
+except NameError:
+ from sets import Set as set
+
from django.db import models
class Article(models.Model):
@@ -389,4 +394,10 @@ year, including Jan. 1 and Dec. 31.
>>> a.save()
>>> Article.objects.get(pk=a.id).headline
u'\u6797\u539f \u3081\u3050\u307f'
+
+# Model instances have a hash function, so they can be used in sets or as
+# dictionary keys. Two models compare as equal if their primary keys are equal.
+>>> s = set([a10, a11, a12])
+>>> Article.objects.get(headline='Article 11') in s
+True
"""
diff --git a/tests/regressiontests/datastructures/tests.py b/tests/regressiontests/datastructures/tests.py
index b5dc5d171b..172057f080 100644
--- a/tests/regressiontests/datastructures/tests.py
+++ b/tests/regressiontests/datastructures/tests.py
@@ -77,6 +77,8 @@ MultiValueDictKeyError: "Key 'lastname' not found in <MultiValueDict: {'position
'not one'
>>> d.keys() == d.copy().keys()
True
+>>> d2 = d.copy()
+>>> d2['four'] = 'four'
>>> print repr(d)
{'one': 'not one', 'two': 'two', 'three': 'three'}
>>> d.pop('one', 'missing')