diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-30 22:41:49 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2009-03-30 22:41:49 +0000 |
| commit | 6ce25d3be9804ca199b65110d10240559293a917 (patch) | |
| tree | 41033295dbddca35a7516b6466b9ba7319e9cfd8 /tests | |
| parent | c8ad87c2dcae02dee537dd51b4661c6411163453 (diff) | |
Fixed #10413: RelatedManager.add no longer fails silenty when trying to add an object of the wrong type. Thanks, dgouldin.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10226 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/many_to_many/models.py | 6 | ||||
| -rw-r--r-- | tests/modeltests/many_to_one/models.py | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/tests/modeltests/many_to_many/models.py b/tests/modeltests/many_to_many/models.py index cc34c868b9..21b4e82aa0 100644 --- a/tests/modeltests/many_to_many/models.py +++ b/tests/modeltests/many_to_many/models.py @@ -61,6 +61,12 @@ ValueError: 'Article' instance needs to have a primary key value before a many-t # Adding a second time is OK >>> a2.publications.add(p3) +# Adding an object of the wrong type raises TypeError +>>> a2.publications.add(a1) +Traceback (most recent call last): +... +TypeError: 'Publication' instance expected + # Add a Publication directly via publications.add by using keyword arguments. >>> new_publication = a2.publications.create(title='Highlights for Children') diff --git a/tests/modeltests/many_to_one/models.py b/tests/modeltests/many_to_one/models.py index 1972ac72ee..8093e73013 100644 --- a/tests/modeltests/many_to_one/models.py +++ b/tests/modeltests/many_to_one/models.py @@ -72,6 +72,13 @@ __test__ = {'API_TESTS':""" >>> r2.article_set.add(new_article2) >>> new_article2.reporter.id 2 + +# Adding an object of the wrong type raises TypeError +>>> r.article_set.add(r2) +Traceback (most recent call last): +... +TypeError: 'Article' instance expected + >>> r.article_set.all() [<Article: John's second story>, <Article: This is a test>] >>> r2.article_set.all() |
