Changeset 4193

Show
Ignore:
Timestamp:
03/02/08 06:11:57 (9 months ago)
Author:
chrisz
Message:

Adapted unittest for fix in r4192 and merged this to 1.1.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/turbogears/tests/test_validators.py

    r4183 r4193  
    7070            not_empty=True).to_python(empty_field_storage) 
    7171    except validators.Invalid: 
    72         v = 'invalid' 
    73     assert v == 'invalid', 'mandatory filename not ensured' 
     72        v = None 
     73    assert v is None, 'mandatory filename not ensured' 
    7474    # test for ticket #1705 
    7575    try: 
     
    7777            not_empty=False).to_python(empty_field_storage) 
    7878    except validators.Invalid: 
    79         v = 'invalid' 
    80     assert v is None, 'optional filename not validated' 
     79        v = None 
     80    assert v is empty_field_storage, 'optional filename not validated' 
  • branches/1.0/turbogears/validators.py

    r4192 r4193  
    147147    def _to_python(self, value, state=None): 
    148148        try: 
    149             fname = value.filename 
     149            filename = value.filename 
    150150        except AttributeError: 
    151             value = None 
    152  
    153         if not fname and self.not_empty: 
     151            filename = None 
     152        if not filename and self.not_empty: 
    154153            raise Invalid(self.message('notEmpty', state), value, state) 
    155  
    156154        return value 
    157155 
  • branches/1.1/turbogears/tests/test_validators.py

    r4183 r4193  
    6969            not_empty=True).to_python(empty_field_storage) 
    7070    except validators.Invalid: 
    71         v = 'invalid' 
    72     assert v == 'invalid', 'mandatory filename not ensured' 
     71        v = None 
     72    assert v is None, 'mandatory filename not ensured' 
    7373    # test for ticket #1705 
    7474    try: 
     
    7676            not_empty=False).to_python(empty_field_storage) 
    7777    except validators.Invalid: 
    78         v = 'invalid' 
    79     assert v is None, 'optional filename not validated' 
     78        v = None 
     79    assert v is empty_field_storage, 'optional filename not validated' 
  • branches/1.1/turbogears/validators.py

    r4183 r4193  
    147147    def _to_python(self, value, state=None): 
    148148        try: 
    149             value = value.filename 
     149            filename = value.filename 
    150150        except AttributeError: 
    151             value = None 
    152         if not value and self.not_empty: 
     151            filename = None 
     152        if not filename and self.not_empty: 
    153153            raise Invalid(self.message('notEmpty', state), value, state) 
    154154        return value