Django

Code

Ticket #7331: 7331.diff

File 7331.diff, 1.1 kB (added by jurev, 1 year ago)

MultiValueDict?.iteritems() patch with unittest

  • django/utils/datastructures.py

    old new  
    266266        """ 
    267267        return [(key, self[key]) for key in self.keys()] 
    268268 
     269    def iteritems(self): 
     270        """ 
     271        Yields (key, value) pairs, where value is the last item in 
     272        the list associated with the key. 
     273        """ 
     274        for key in self.keys(): 
     275            yield (key, self[key]) 
     276     
    269277    def lists(self): 
    270278        """Returns a list of (key, list) pairs.""" 
    271279        return super(MultiValueDict, self).items() 
  • tests/regressiontests/datastructures/tests.py

    old new  
    4242'Simon' 
    4343>>> d.getlist('name') 
    4444['Adrian', 'Simon'] 
     45>>> list(d.iteritems()) 
     46[('position', 'Developer'), ('name', 'Simon')] 
    4547>>> d['lastname'] 
    4648Traceback (most recent call last): 
    4749...