Ticket #6868: 6868_filepathfield_tests.diff

File 6868_filepathfield_tests.diff, 2.8 KB (added by Ned Batchelder, 17 years ago)

the patch, without spurious blank line

  • tests/regressiontests/forms/fields.py

     
    11351135
    11361136# FilePathField ###############################################################
    11371137
     1138>>> def fix_os_paths(x):
     1139...     if isinstance(x, basestring):
     1140...         return x.replace('\\', '/')
     1141...     elif isinstance(x, tuple):
     1142...         return tuple(fix_os_paths(list(x)))
     1143...     elif isinstance(x, list):
     1144...         return [fix_os_paths(y) for y in x]
     1145...     else:
     1146...         return x
     1147...
    11381148>>> import os
    11391149>>> from django import newforms as forms
    11401150>>> path = forms.__file__
    11411151>>> path = os.path.dirname(path) + '/'
    1142 >>> path
     1152>>> fix_os_paths(path)
    11431153'.../django/newforms/'
    11441154>>> f = forms.FilePathField(path=path)
    11451155>>> f.choices.sort()
    1146 >>> f.choices
     1156>>> fix_os_paths(f.choices)
    11471157[('.../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')]
    11481158>>> f.clean('fields.py')
    11491159Traceback (most recent call last):
    11501160...
    11511161ValidationError: [u'Select a valid choice. That choice is not one of the available choices.']
    1152 >>> f.clean(path + 'fields.py')
     1162>>> fix_os_paths(f.clean(path + 'fields.py'))
    11531163u'.../django/newforms/fields.py'
    11541164>>> f = forms.FilePathField(path=path, match='^.*?\.py$')
    11551165>>> f.choices.sort()
    1156 >>> f.choices
     1166>>> fix_os_paths(f.choices)
    11571167[('.../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')]
    11581168>>> f = forms.FilePathField(path=path, recursive=True, match='^.*?\.py$')
    11591169>>> f.choices.sort()
    1160 >>> f.choices
     1170>>> fix_os_paths(f.choices)
    11611171[('.../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')]
    11621172
    11631173# SplitDateTimeField ##########################################################
Back to Top