diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2007-09-15 21:46:18 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2007-09-15 21:46:18 +0000 |
| commit | 7325fbf4ff20f9b0f21d3a1aba1abaca78a765d7 (patch) | |
| tree | 8276758a973d926f7fa43377b5ef4d07ed2eb517 /tests | |
| parent | 5ce2e6c2c827cf877f73bf0e42e6afb7e6a71ccf (diff) | |
queryset-refactor: Merged to [6250]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6339 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/model_forms/models.py | 14 | ||||
| -rw-r--r-- | tests/regressiontests/backends/models.py | 6 | ||||
| -rw-r--r-- | tests/regressiontests/fixtures_regress/models.py | 8 |
3 files changed, 15 insertions, 13 deletions
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py index 47407573dd..bc14c117d5 100644 --- a/tests/modeltests/model_forms/models.py +++ b/tests/modeltests/model_forms/models.py @@ -115,7 +115,7 @@ True >>> obj = f.save() >>> obj <Category: It's a test> ->>> Category.objects.all() +>>> Category.objects.order_by('name') [<Category: Entertainment>, <Category: It's a test>] If you call save() with commit=False, then it will return an object that @@ -129,10 +129,10 @@ True >>> obj = f.save(commit=False) >>> obj <Category: Third test> ->>> Category.objects.all() +>>> Category.objects.order_by('name') [<Category: Entertainment>, <Category: It's a test>] >>> obj.save() ->>> Category.objects.all() +>>> Category.objects.order_by('name') [<Category: Entertainment>, <Category: It's a test>, <Category: Third test>] If you call save() with invalid data, you'll get a ValueError. @@ -306,7 +306,7 @@ Add some categories and test the many-to-many form output. >>> new_art.id 1 >>> new_art = Article.objects.get(id=1) ->>> new_art.categories.all() +>>> new_art.categories.order_by('name') [<Category: Entertainment>, <Category: It's a test>] Now, submit form data with no categories. This deletes the existing categories. @@ -327,7 +327,7 @@ Create a new article, with categories, via the form. >>> new_art.id 2 >>> new_art = Article.objects.get(id=2) ->>> new_art.categories.all() +>>> new_art.categories.order_by('name') [<Category: Entertainment>, <Category: It's a test>] Create a new article, with no categories, via the form. @@ -348,7 +348,7 @@ The m2m data won't be saved until save_m2m() is invoked on the form. ... 'writer': u'1', 'article': u'Test.', 'categories': [u'1', u'2']}) >>> new_art = f.save(commit=False) -# Manually save the instance +# Manually save the instance >>> new_art.save() >>> new_art.id 4 @@ -360,7 +360,7 @@ The m2m data won't be saved until save_m2m() is invoked on the form. # Save the m2m data on the form >>> f.save_m2m() ->>> new_art.categories.all() +>>> new_art.categories.order_by('name') [<Category: Entertainment>, <Category: It's a test>] Here, we define a custom Form. Because it happens to have the same fields as diff --git a/tests/regressiontests/backends/models.py b/tests/regressiontests/backends/models.py index 50a628a22e..a455f21e67 100644 --- a/tests/regressiontests/backends/models.py +++ b/tests/regressiontests/backends/models.py @@ -17,11 +17,7 @@ __test__ = {'API_TESTS': """ >>> Square.objects.order_by('root') [<Square: -5 ** 2 == 25>, <Square: -4 ** 2 == 16>, <Square: -3 ** 2 == 9>, <Square: -2 ** 2 == 4>, <Square: -1 ** 2 == 1>, <Square: 0 ** 2 == 0>, <Square: 1 ** 2 == 1>, <Square: 2 ** 2 == 4>, <Square: 3 ** 2 == 9>, <Square: 4 ** 2 == 16>, <Square: 5 ** 2 == 25>] -#4765: executemany with params=None or params=[] does nothing ->>> cursor.executemany('INSERT INTO BACKENDS_SQUARE (ROOT, SQUARE) VALUES (%s, %s)', None) and None or None ->>> Square.objects.count() -11 - +#4765: executemany with params=[] does nothing >>> cursor.executemany('INSERT INTO BACKENDS_SQUARE (ROOT, SQUARE) VALUES (%s, %s)', []) and None or None >>> Square.objects.count() 11 diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py index c6a50f73ce..a62925eb37 100644 --- a/tests/regressiontests/fixtures_regress/models.py +++ b/tests/regressiontests/fixtures_regress/models.py @@ -1,5 +1,6 @@ from django.db import models from django.contrib.auth.models import User +from django.conf import settings class Animal(models.Model): name = models.CharField(max_length=150) @@ -20,7 +21,12 @@ class Stuff(models.Model): owner = models.ForeignKey(User, null=True) def __unicode__(self): - return unicode(self.name) + u' is owned by ' + unicode(self.owner) + # Oracle doesn't distinguish between None and the empty string. + # This hack makes the test case pass using Oracle. + name = self.name + if settings.DATABASE_ENGINE == 'oracle' and name == u'': + name = None + return unicode(name) + u' is owned by ' + unicode(self.owner) __test__ = {'API_TESTS':""" >>> from django.core import management |
