Added more tests, fixed compat.py to run on py3 as well
This commit is contained in:
1 parent
b2ccc754f4
commit
a5a76a8e1c
5 files changed
+101
-59
No files matched your search
+1
-1
@@ -15,5 +15,5 @@ both Python2 and Python3 while using the same codebase.
|
||||
try:
|
||||
input = raw_input
|
||||
except NameError:
|
||||
pass
|
||||
input = input
|
||||
# pylint: enable=undefined-variable,redefined-builtin,invalid-name
|
||||
@@ -54,9 +54,14 @@ class Packet(object):
|
||||
id = -0x01
|
||||
definition = []
|
||||
|
||||
def __init__(self):
|
||||
def __init__(self, **kwargs):
|
||||
pass
|
||||
|
||||
def set_values(self, **kwargs):
|
||||
for key, value in kwargs.items():
|
||||
setattr(self, key, value)
|
||||
return self
|
||||
|
||||
def read(self, file_object):
|
||||
for field in self.definition:
|
||||
for var_name, data_type in field.items():
|
||||
|
||||
@@ -8,11 +8,11 @@ import struct
|
||||
class Type(object):
|
||||
@staticmethod
|
||||
def read(file_object):
|
||||
pass
|
||||
raise NotImplementedError("Base data type not serializable")
|
||||
|
||||
@staticmethod
|
||||
def send(value, socket):
|
||||
pass
|
||||
raise NotImplementedError("Base data type not serializable")
|
||||
|
||||
|
||||
# =========================================================
|
||||
@@ -84,7 +84,7 @@ class VarInt(Type):
|
||||
number = 0
|
||||
for i in range(5):
|
||||
byte = socket.recv(1)
|
||||
if byte == "":
|
||||
if byte == "" or len(byte) == 0:
|
||||
raise RuntimeError("Socket disconnected")
|
||||
byte = ord(byte)
|
||||
number |= (byte & 0x7F) << 7 * i
|
||||
|
||||
Reference in new issue
Block a user