diff options
| author | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-03-19 22:29:11 +0000 |
|---|---|---|
| committer | Jacob Kaplan-Moss <jacob@jacobian.org> | 2008-03-19 22:29:11 +0000 |
| commit | 4457ba002d64d4a991b0561c5be69a8c61b2b828 (patch) | |
| tree | 6251d21048f862d93fc9f011c40d3e63e87b46c5 /tests/regressiontests/forms/fields.py | |
| parent | bc1f67a6de45fe2ebfdf69ba449295066f365419 (diff) | |
Fixed #5894: added FilePathField to newforms. Thanks, Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7323 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms/fields.py')
| -rw-r--r-- | tests/regressiontests/forms/fields.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py index 9216210e09..9421d8c005 100644 --- a/tests/regressiontests/forms/fields.py +++ b/tests/regressiontests/forms/fields.py @@ -1133,6 +1133,33 @@ u'' >>> f.clean(None) u'' +# FilePathField ############################################################### + +>>> import os +>>> from django import newforms as forms +>>> path = forms.__file__ +>>> path = os.path.dirname(path) + '/' +>>> path +'.../django/newforms/' +>>> f = forms.FilePathField(path=path) +>>> f.choices.sort() +>>> 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') +u'.../django/newforms/fields.py' +>>> f = forms.FilePathField(path=path, match='^.*?\.py$') +>>> f.choices.sort() +>>> 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 +[('.../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 ########################################################## >>> f = SplitDateTimeField() |
