From 80860229209b4c6eb8384e1bca3cabdbe062fe6e Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 30 Apr 2015 09:04:22 +1200 Subject: Add a tiny utility class for keeping bi-directional mappings. Use it in websocket and socks. --- test/test_utils.py | 11 ++++++++++- test/test_websockets.py | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_utils.py b/test/test_utils.py index 971e5076..0cdd3fae 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -1,5 +1,14 @@ from netlib import utils -import socket +import tutils + + +def test_bidi(): + b = utils.BiDi(a=1, b=2) + assert b.a == 1 + assert b[1] == "a" + tutils.raises(AttributeError, getattr, b, "c") + tutils.raises(KeyError, b.__getitem__, 5) + def test_hexdump(): assert utils.hexdump("one\0"*10) diff --git a/test/test_websockets.py b/test/test_websockets.py index 4b286b6f..9266d93e 100644 --- a/test/test_websockets.py +++ b/test/test_websockets.py @@ -184,6 +184,10 @@ class TestFrameHeader: round(opcode=websockets.OPCODE.PING) round(masking_key="test") + def test_human_readable(self): + f = websockets.FrameHeader(masking_key="test", mask=False) + assert f.human_readable() + def test_funky(self): f = websockets.FrameHeader(masking_key="test", mask=False) bytes = f.to_bytes() -- cgit v1.2.3