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.