@@ -47,12 +47,13 @@ class Attribute(StringMixIn): | |||||
self._pad_after_eq = pad_after_eq | self._pad_after_eq = pad_after_eq | ||||
def __unicode__(self): | def __unicode__(self): | ||||
base = self.pad_first + str(self.name) + self.pad_before_eq | |||||
result = self.pad_first + str(self.name) + self.pad_before_eq | |||||
if self.value is not None: | if self.value is not None: | ||||
result += "=" + self.pad_after_eq | |||||
if self.quoted: | if self.quoted: | ||||
return base + '="' + self.pad_after_eq + str(self.value) + '"' | |||||
return base + "=" + self.pad_after_eq + str(self.value) | |||||
return base | |||||
return result + '"' + str(self.value) + '"' | |||||
return result + str(self.value) | |||||
return result | |||||
def _set_padding(self, attr, value): | def _set_padding(self, attr, value): | ||||
"""Setter for the value of a padding attribute.""" | """Setter for the value of a padding attribute.""" | ||||
@@ -38,6 +38,8 @@ class TestAttribute(TreeEqualityTestCase): | |||||
self.assertEqual(" foo", str(node)) | self.assertEqual(" foo", str(node)) | ||||
node2 = Attribute(wraptext("foo"), wraptext("bar")) | node2 = Attribute(wraptext("foo"), wraptext("bar")) | ||||
self.assertEqual(' foo="bar"', str(node2)) | self.assertEqual(' foo="bar"', str(node2)) | ||||
node3 = Attribute(wraptext("a"), wraptext("b"), True, "", " ", " ") | |||||
self.assertEqual('a = "b"', str(node3)) | |||||
node3 = Attribute(wraptext("a"), wraptext("b"), False, "", " ", " ") | node3 = Attribute(wraptext("a"), wraptext("b"), False, "", " ", " ") | ||||
self.assertEqual("a = b", str(node3)) | self.assertEqual("a = b", str(node3)) | ||||
node4 = Attribute(wraptext("a"), wrap([]), False, " ", "", " ") | node4 = Attribute(wraptext("a"), wrap([]), False, " ", "", " ") | ||||