Added a few more tests for `MultiValueDict`.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@6715 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gary Wilson Jr 2007-11-25 18:16:40 +00:00
parent c7181ec0ff
commit 5903b0bdcd
1 changed files with 12 additions and 0 deletions

View File

@ -25,11 +25,23 @@
>>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']}) >>> d = MultiValueDict({'name': ['Adrian', 'Simon'], 'position': ['Developer']})
>>> d['name'] >>> d['name']
'Simon' 'Simon'
>>> d.get('name')
'Simon'
>>> d.getlist('name') >>> d.getlist('name')
['Adrian', 'Simon'] ['Adrian', 'Simon']
>>> d['lastname']
Traceback (most recent call last):
...
MultiValueDictKeyError: "Key 'lastname' not found in <MultiValueDict: {'position': ['Developer'], 'name': ['Adrian', 'Simon']}>"
>>> d.get('lastname')
>>> d.get('lastname', 'nonexistent') >>> d.get('lastname', 'nonexistent')
'nonexistent' 'nonexistent'
>>> d.getlist('lastname')
[]
>>> d.setlist('lastname', ['Holovaty', 'Willison']) >>> d.setlist('lastname', ['Holovaty', 'Willison'])
>>> d.getlist('lastname')
['Holovaty', 'Willison']
### SortedDict ################################################################# ### SortedDict #################################################################