diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-01 00:28:15 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-04-01 00:28:15 +0000 |
| commit | 4efe9675c5fd5a030737d957b3588184f06117fe (patch) | |
| tree | b3ea195f6a3a281428c9cd5789e386493edc5379 /tests | |
| parent | 70913a2c4358de7341525ab0e913fafd213022c2 (diff) | |
queryset-refactor: Merged from trunk up to [7388].
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@7396 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/modeltests/or_lookups/models.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/forms/fields.py | 20 | ||||
| -rw-r--r-- | tests/regressiontests/model_regress/models.py | 17 |
3 files changed, 33 insertions, 6 deletions
diff --git a/tests/modeltests/or_lookups/models.py b/tests/modeltests/or_lookups/models.py index 38339c0685..c779e19e37 100644 --- a/tests/modeltests/or_lookups/models.py +++ b/tests/modeltests/or_lookups/models.py @@ -103,7 +103,7 @@ __test__ = {'API_TESTS':""" >>> Article.objects.filter(Q(pk=1) & (~Q(pk=2) | Q(pk=3))) [<Article: Hello>] -# Try some arg queries with operations other than get_list +# Try some arg queries with operations other than filter. >>> Article.objects.get(Q(headline__startswith='Hello'), Q(headline__contains='bye')) <Article: Hello and goodbye> diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py index 9421d8c005..f3b6a96a1e 100644 --- a/tests/regressiontests/forms/fields.py +++ b/tests/regressiontests/forms/fields.py @@ -1135,29 +1135,39 @@ u'' # FilePathField ############################################################### +>>> def fix_os_paths(x): +... if isinstance(x, basestring): +... return x.replace('\\', '/') +... elif isinstance(x, tuple): +... return tuple(fix_os_paths(list(x))) +... elif isinstance(x, list): +... return [fix_os_paths(y) for y in x] +... else: +... return x +... >>> import os >>> from django import newforms as forms >>> path = forms.__file__ >>> path = os.path.dirname(path) + '/' ->>> path +>>> fix_os_paths(path) '.../django/newforms/' >>> f = forms.FilePathField(path=path) >>> f.choices.sort() ->>> f.choices +>>> fix_os_paths(f.choices) [('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/__init__.pyc', '__init__.pyc'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/fields.pyc', 'fields.pyc'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/forms.pyc', 'forms.pyc'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/models.pyc', 'models.pyc'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/util.pyc', 'util.pyc'), ('.../django/newforms/widgets.py', 'widgets.py'), ('.../django/newforms/widgets.pyc', 'widgets.pyc')] >>> f.clean('fields.py') Traceback (most recent call last): ... ValidationError: [u'Select a valid choice. That choice is not one of the available choices.'] ->>> f.clean(path + 'fields.py') +>>> fix_os_paths(f.clean(path + 'fields.py')) u'.../django/newforms/fields.py' >>> f = forms.FilePathField(path=path, match='^.*?\.py$') >>> f.choices.sort() ->>> f.choices +>>> fix_os_paths(f.choices) [('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')] >>> f = forms.FilePathField(path=path, recursive=True, match='^.*?\.py$') >>> f.choices.sort() ->>> f.choices +>>> fix_os_paths(f.choices) [('.../django/newforms/__init__.py', '__init__.py'), ('.../django/newforms/extras/__init__.py', 'extras/__init__.py'), ('.../django/newforms/extras/widgets.py', 'extras/widgets.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')] # SplitDateTimeField ########################################################## diff --git a/tests/regressiontests/model_regress/models.py b/tests/regressiontests/model_regress/models.py index 02e73a5aa9..2252531564 100644 --- a/tests/regressiontests/model_regress/models.py +++ b/tests/regressiontests/model_regress/models.py @@ -26,6 +26,9 @@ class Movie(models.Model): movie_id = models.AutoField(primary_key=True) name = models.CharField(max_length=60) +class Party(models.Model): + when = models.DateField() + __test__ = {'API_TESTS': """ (NOTE: Part of the regression test here is merely parsing the model declaration. The verbose_name, in particular, did not always work.) @@ -51,5 +54,19 @@ u'' >>> len(a4.article_text) 5000 +# #659 regression test +>>> import datetime +>>> p = Party.objects.create(when = datetime.datetime(1999, 12, 31)) +>>> p = Party.objects.create(when = datetime.datetime(1998, 12, 31)) +>>> p = Party.objects.create(when = datetime.datetime(1999, 1, 1)) +>>> [p.when for p in Party.objects.filter(when__month = 2)] +[] +>>> [p.when for p in Party.objects.filter(when__month = 1)] +[datetime.date(1999, 1, 1)] +>>> [p.when for p in Party.objects.filter(when__month = 12)] +[datetime.date(1999, 12, 31), datetime.date(1998, 12, 31)] +>>> [p.when for p in Party.objects.filter(when__year = 1998)] +[datetime.date(1998, 12, 31)] + """ } |
