1 from test
import test_support
6 class XDRTest(unittest
.TestCase
):
12 a
= ['what', 'is', 'hapnin', 'doctor']
22 p
.pack_list(range(5), p
.pack_uint
)
23 p
.pack_array(a
, p
.pack_string
)
27 up
= xdrlib
.Unpacker(data
)
29 self
.assertEqual(up
.get_position(), 0)
31 self
.assertEqual(up
.unpack_int(), 42)
32 self
.assertEqual(up
.unpack_uint(), 9)
33 self
.assert_(up
.unpack_bool() is True)
36 pos
= up
.get_position()
37 self
.assert_(up
.unpack_bool() is False)
39 # rewind and unpack again
41 self
.assert_(up
.unpack_bool() is False)
43 self
.assertEqual(up
.unpack_uhyper(), 45L)
44 self
.assertAlmostEqual(up
.unpack_float(), 1.9)
45 self
.assertAlmostEqual(up
.unpack_double(), 1.9)
46 self
.assertEqual(up
.unpack_string(), s
)
47 self
.assertEqual(up
.unpack_list(up
.unpack_uint
), range(5))
48 self
.assertEqual(up
.unpack_array(up
.unpack_string
), a
)
50 self
.assertRaises(EOFError, up
.unpack_uint
)
53 test_support
.run_unittest(XDRTest
)
55 if __name__
== "__main__":