From 76d4bb128c61b8e525186b6a254f16571511b860 Mon Sep 17 00:00:00 2001 From: speyrefitte Date: Wed, 2 Apr 2014 16:48:37 +0200 Subject: [PATCH] Add test for network.type --- README.md | 1 + rdpy/dotest.py | 18 ++ rdpy/network/type.py | 19 +- rdpy/test/__init__.py | 0 rdpy/test/network/__init__.py | 0 rdpy/test/network/type.py | 330 ++++++++++++++++++++++++++++++++++ 6 files changed, 366 insertions(+), 2 deletions(-) create mode 100644 rdpy/dotest.py create mode 100644 rdpy/test/__init__.py create mode 100644 rdpy/test/network/__init__.py create mode 100644 rdpy/test/network/type.py diff --git a/README.md b/README.md index 7c7814d..e30f691 100644 --- a/README.md +++ b/README.md @@ -1 +1,2 @@ depend : python-qt4, python-twisted, python-qt4reactor +this project is still in progress. diff --git a/rdpy/dotest.py b/rdpy/dotest.py new file mode 100644 index 0000000..49cc586 --- /dev/null +++ b/rdpy/dotest.py @@ -0,0 +1,18 @@ +''' +@author: sylvain +''' +import sys, os +# Change path so we find rdpy +sys.path.insert(1, os.path.join(sys.path[0], '..')) +import unittest, rdpy.test.network.type + +def headerTest(name): + print "-"*40 + print name + print "-"*40 + +if __name__ == '__main__': + headerTest("Test case rdpy.test.network.type.TypeCase") + suite = unittest.TestLoader().loadTestsFromTestCase(rdpy.test.network.type.TypeCase) + unittest.TextTestRunner(verbosity=2).run(suite) + diff --git a/rdpy/network/type.py b/rdpy/network/type.py index 4f4559d..1e31c46 100644 --- a/rdpy/network/type.py +++ b/rdpy/network/type.py @@ -563,9 +563,17 @@ class UInt24Be(SimpleType): def __write__(self, s): ''' special write for a special type + @param s: Stream ''' s.write(struct.pack(">I", self.value)[1:]) + def __read__(self, s): + ''' + special read for a special type + @param s: Stream + ''' + self.value = struct.unpack(self._structFormat, '\x00' + s.read(self._typeSize))[0] + class UInt24Le(SimpleType): ''' unsigned int with little endian representation @@ -587,7 +595,14 @@ class UInt24Le(SimpleType): @param s: Stream ''' #don't write first byte - s.write(struct.pack("