From cf6519fb022ba4ff640c2f106186aa5643912763 Mon Sep 17 00:00:00 2001 From: David Glick Date: Sat, 27 Feb 2010 03:54:47 +0000 Subject: [PATCH] rewrite 2 tests to avoid pprint, which sorts dictionaries differently in Python 2.4 and 2.5+ --- CHANGES.txt | 3 +++ src/z3c/form/field.txt | 10 +++++++--- src/z3c/form/form.txt | 16 ++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 67f4b926..3cf91800 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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. diff --git a/src/z3c/form/field.txt b/src/z3c/form/field.txt index 05c7282c..6d9342dd 100644 --- a/src/z3c/form/field.txt +++ b/src/z3c/form/field.txt @@ -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: diff --git a/src/z3c/form/form.txt b/src/z3c/form/form.txt index 4ea40f33..582f2ab0 100644 --- a/src/z3c/form/form.txt +++ b/src/z3c/form/form.txt @@ -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