Check the path output in unittests are difficult, if a form widget
should be checked.

The Problem:
The widget html attribute order is not contingent and may change from
test to tests, because they come from a python dict witch is
unordered...

A simple patch could fix this, by adding sorted() to
forms.util.flatatt():

-------------------------------------------------------------------------------------------------------------------
diff --git a/django/forms/util.py b/django/forms/util.py
index 1a1d823..8a48009 100644
--- a/django/forms/util.py
+++ b/django/forms/util.py
@@ -13,7 +13,7 @@ def flatatt(attrs):
     XML-style pairs.  It is assumed that the keys do not need to be
XML-escaped.
     If the passed dictionary is empty, then return an empty string.
     """
-    return u''.join([u' %s="%s"' % (k, conditional_escape(v)) for k,
v in attrs.items()])
+    return u''.join([u' %s="%s"' % (k, conditional_escape(v)) for k,
v in sorted(attrs.items())])

 class ErrorDict(dict, StrAndUnicode):
     """
-------------------------------------------------------------------------------------------------------------------
see also: https://gist.github.com/976467

Should i open a ticked for this?

Mfg.

Jens D.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to