Skip to content

Commit

Permalink
rewrite 2 tests to avoid pprint, which sorts dictionaries differently…
Browse files Browse the repository at this point in the history
… in Python 2.4 and 2.5+
  • Loading branch information
davisagli committed Feb 27, 2010
1 parent d38079c commit cf6519f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ CHANGES
2.3.3 (unreleased)
------------------

- Fix trivial test failures on Python 2.4 stemming from differences in
pprint's sorting of dicts.

- Don't invoke render() when publishing the form as a view if the HTTP status
code has been set to one in the 3xx range (e.g. a redirect or not-modified
response) - the response body will be ignored by the browser anyway.
Expand Down
10 changes: 7 additions & 3 deletions src/z3c/form/field.txt
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,13 @@ empty:
>>> manager.ignoreContext = True
>>> manager.update()

>>> from pprint import pprint
>>> pprint(manager.extract())
({'firstName': u'Stephan', 'lastName': u'Richter'}, ())
>>> data, errors = manager.extract()
>>> data['firstName']
u'Stephan'
>>> data['lastName']
u'Richter'
>>> errors
()

Since all errors are immediately converted to error view snippets, we have to
provide the adapter from a validation error to an error view snippet first:
Expand Down
16 changes: 10 additions & 6 deletions src/z3c/form/form.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1119,12 +1119,16 @@ the dictionary:
>>> editForm = PersonDictEditForm(None, request)
>>> editForm.update()

>>> from pprint import pprint
>>> pprint(personDict)
{'age': 5,
'gender': 'male',
'id': u'rineichen',
'name': u'Jesse Ineichen'}
>>> len(personDict)
4
>>> personDict['age']
5
>>> personDict['gender']
'male'
>>> personDict['id']
u'rineichen'
>>> personDict['name']
u'Jesse Ineichen'


Creating a Display Form
Expand Down

0 comments on commit cf6519f

Please sign in to comment.