SettingUpClientServer (#7)

Reviewed-on: #7
This commit is contained in:
2023-01-19 16:08:23 +00:00
parent 95459c5b02
commit 21a397861a
19 changed files with 2480 additions and 2 deletions
+35
View File
@@ -0,0 +1,35 @@
import io
from sdp.sheerkaSerializer import JsonSerializer
class ObjNoKey:
"""
Object with no key, they won't be ordered
Not suitable for Json dump as there is no to_dict() method
"""
def __init__(self, a, b):
self.a = a
self.b = b
def __hash__(self):
return hash((self.a, self.b))
def __eq__(self, obj):
return isinstance(obj, ObjNoKey) and \
self.a == obj.a and \
self.b == obj.b
def __repr__(self):
return f"ObjNoKey({self.a}, {self.b})"
def test_i_can_json_serialize():
json_serializer = JsonSerializer(lambda obj: True)
obj = ObjNoKey("a", "b")
stream = io.BytesIO()
stream = json_serializer.dump(stream, obj, None)
res = json_serializer.load(stream, None)
assert res == obj