From ef7b2b7eaf8f6f786133869e0b22cfdda15844a8 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Wed, 7 Nov 2018 13:31:33 +0100 Subject: [PATCH] Fix FormattedString test failure. Initialize FormattedString().attributes to DEFAULT_ATTRIBUTES so all the attributes are always present. FormattedString is now a class, not a namedtuple instance. --- matrix/colors.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/matrix/colors.py b/matrix/colors.py index 261a5bd..96a4c24 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -43,7 +43,13 @@ except ImportError: from html.parser import HTMLParser -FormattedString = namedtuple("FormattedString", ["text", "attributes"]) +class FormattedString: + __slots__ = ("text", "attributes") + + def __init__(self, text, attributes): + self.attributes = DEFAULT_ATTRIBUTES.copy() + self.attributes.update(attributes) + self.text = text class Formatted(object):