summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test.py8
-rw-r--r--viewstate.py16
2 files changed, 12 insertions, 12 deletions
diff --git a/test.py b/test.py
index 1f84bc2..c0cfc10 100644
--- a/test.py
+++ b/test.py
@@ -19,10 +19,10 @@ class TestViewState(unittest.TestCase):
vs.raw = b'\x01\x02'
vs.decode()
- # def test_parse(self):
- # vs = ViewState()
- # vs.raw = b'\xff\x01\x67'
- # self.assertTrue(vs.decode())
+ def test_parse_const_value(self):
+ vs = ViewState()
+ vs.raw = b'\xff\x01\x67'
+ self.assertEquals(vs.decode(), True)
if __name__ == '__main__':
unittest.main()
diff --git a/viewstate.py b/viewstate.py
index 01417a4..bf14005 100644
--- a/viewstate.py
+++ b/viewstate.py
@@ -2,17 +2,17 @@ from base64 import b64decode, b64encode
CONSTS = {
- '\x64': {},
- '\x65': '',
- '\x66': 0,
- '\x67': True,
- '\x68': False
+ 100: {},
+ 101: '',
+ 102: 0,
+ 103: True,
+ 104: False
}
def parse(b):
- print([hex(x) for x in b])
- if len(b) == 1 and b in CONSTS:
- return CONSTS[b]
+ assert type(b) == bytes().__class__
+ if len(b) == 1 and b[0] in CONSTS:
+ return CONSTS[b[0]]
return None