diff options
Diffstat (limited to 'Lib/xdrlib.py')
-rw-r--r-- | Lib/xdrlib.py | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py index b349eb9..796dfaf 100644 --- a/Lib/xdrlib.py +++ b/Lib/xdrlib.py @@ -227,61 +227,3 @@ class Unpacker: def unpack_array(self, unpack_item): n = self.unpack_uint() return self.unpack_farray(n, unpack_item) - - -# test suite -def _test(): - p = Packer() - packtest = [ - (p.pack_uint, (9,)), - (p.pack_bool, (True,)), - (p.pack_bool, (False,)), - (p.pack_uhyper, (45L,)), - (p.pack_float, (1.9,)), - (p.pack_double, (1.9,)), - (p.pack_string, ('hello world',)), - (p.pack_list, (range(5), p.pack_uint)), - (p.pack_array, (['what', 'is', 'hapnin', 'doctor'], p.pack_string)), - ] - succeedlist = [1] * len(packtest) - count = 0 - for method, args in packtest: - print 'pack test', count, - try: - method(*args) - print 'succeeded' - except ConversionError, var: - print 'ConversionError:', var.msg - succeedlist[count] = 0 - count = count + 1 - data = p.get_buffer() - # now verify - up = Unpacker(data) - unpacktest = [ - (up.unpack_uint, (), lambda x: x == 9), - (up.unpack_bool, (), lambda x: x is True), - (up.unpack_bool, (), lambda x: x is False), - (up.unpack_uhyper, (), lambda x: x == 45L), - (up.unpack_float, (), lambda x: 1.89 < x < 1.91), - (up.unpack_double, (), lambda x: 1.89 < x < 1.91), - (up.unpack_string, (), lambda x: x == 'hello world'), - (up.unpack_list, (up.unpack_uint,), lambda x: x == range(5)), - (up.unpack_array, (up.unpack_string,), - lambda x: x == ['what', 'is', 'hapnin', 'doctor']), - ] - count = 0 - for method, args, pred in unpacktest: - print 'unpack test', count, - try: - if succeedlist[count]: - x = method(*args) - print pred(x) and 'succeeded' or 'failed', ':', x - else: - print 'skipping' - except ConversionError, var: - print 'ConversionError:', var.msg - count = count + 1 - - -if __name__ == '__main__': - _test() |