File tree Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Expand file tree Collapse file tree 2 files changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -405,14 +405,14 @@ def to_header(self, realm=''):
405
405
406
406
def to_postdata (self ):
407
407
"""Serialize as post data for a POST request."""
408
- d = {}
409
- for k , v in self .items ():
410
- d [ k .encode ('utf-8' )] = to_utf8_optional_iterator (v )
408
+ items = []
409
+ for k , v in sorted ( self .items ()): # predictable for testing
410
+ items . append (( k .encode ('utf-8' ), to_utf8_optional_iterator (v )) )
411
411
412
412
# tell urlencode to deal with sequence values and map them correctly
413
413
# to resulting querystring. for example self["k"] = ["v1", "v2"] will
414
414
# result in 'k=v1&k=v2' and not k=%5B%27v1%27%2C+%27v2%27%5D
415
- return urlencode (d , True ).replace ('+' , '%20' )
415
+ return urlencode (items , True ).replace ('+' , '%20' )
416
416
417
417
def to_url (self ):
418
418
"""Serialize as a URL for a GET request."""
Original file line number Diff line number Diff line change @@ -499,13 +499,14 @@ def test_to_postdata_nonascii(self):
499
499
self .failUnlessReallyEqual (
500
500
req .to_postdata (),
501
501
('nonasciithing=q%C2%BFu%C3%A9%20%2Caasp%20u%3F..a.s'
502
- '&oauth_nonce=4572616e48616d6d65724c61686176'
503
- '&oauth_timestamp=137131200'
504
502
'&oauth_consumer_key=0685bd9184jfhq22'
503
+ '&oauth_nonce=4572616e48616d6d65724c61686176'
504
+ '&oauth_signature=wOJIO9A2W5mFwDgiDvZbTSMK%252FPY%253D'
505
505
'&oauth_signature_method=HMAC-SHA1'
506
- '&oauth_version=1.0 '
506
+ '&oauth_timestamp=137131200 '
507
507
'&oauth_token=ad180jjd733klru7'
508
- '&oauth_signature=wOJIO9A2W5mFwDgiDvZbTSMK%252FPY%253D' ))
508
+ '&oauth_version=1.0'
509
+ ))
509
510
510
511
def test_to_postdata (self ):
511
512
realm = "http://sp.example.com/"
You can’t perform that action at this time.
0 commit comments