summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2020-02-01 14:33:54 +0200
committerYuval Adam <_@yuv.al>2020-02-01 14:33:54 +0200
commita880d2aa587b9405045a94f723e51c6fb18efd4f (patch)
treead6519d9e966def1f7eb139c126afb32f18b7f07
parent5b39d49ea52d3ffdd0868a1a1f1d6c3b8d0198ec (diff)
Test for unknown colors as wellcolors
-rw-r--r--tests/test_parse.py3
-rw-r--r--viewstate/parse.py4
2 files changed, 5 insertions, 2 deletions
diff --git a/tests/test_parse.py b/tests/test_parse.py
index f5a0828..c1e1abb 100644
--- a/tests/test_parse.py
+++ b/tests/test_parse.py
@@ -45,6 +45,9 @@ class TestParse(object):
vs = ViewState(raw=b"\xff\x01\n\x8d\x01")
assert vs.decode() == "Color: Red"
+ vs = ViewState(raw=b"\xff\x01\n\xff")
+ assert vs.decode() == "Color: Unknown"
+
def test_rgba(self):
vs = ViewState(raw=b"\xff\x01\x09\x10\x20\x30\x40")
assert vs.decode() == "RGBA(16,32,48,64)"
diff --git a/viewstate/parse.py b/viewstate/parse.py
index 910b21b..b2a85f0 100644
--- a/viewstate/parse.py
+++ b/viewstate/parse.py
@@ -122,10 +122,10 @@ class Color(Parser):
@staticmethod
def parse(b):
try:
- color = "Color: {}".format(COLORS[b[0]])
+ color = COLORS[b[0]]
except IndexError:
color = "Unknown"
- return color, b[1:]
+ return "Color: {}".format(color), b[1:]
class Pair(Parser):