diff options
author | Petri Lehtinen <petri@digip.org> | 2014-10-10 18:21:52 (GMT) |
---|---|---|
committer | Petri Lehtinen <petri@digip.org> | 2014-10-10 18:21:52 (GMT) |
commit | 3894b2a24f1a0a94601cc2436f779aa666a2f9dd (patch) | |
tree | ad33521c60dde42da697b9542b3b53a5d4b1e178 /Lib/test/test_xdrlib.py | |
parent | 866c4e2188eba458f8277e8e67a1601cd17b7855 (diff) | |
download | cpython-3894b2a24f1a0a94601cc2436f779aa666a2f9dd.zip cpython-3894b2a24f1a0a94601cc2436f779aa666a2f9dd.tar.gz cpython-3894b2a24f1a0a94601cc2436f779aa666a2f9dd.tar.bz2 |
Issue #11694: Raise ConversionError in xdrlib as documented
Diffstat (limited to 'Lib/test/test_xdrlib.py')
-rw-r--r-- | Lib/test/test_xdrlib.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py index 6004c9f..70496d6 100644 --- a/Lib/test/test_xdrlib.py +++ b/Lib/test/test_xdrlib.py @@ -51,8 +51,32 @@ class XDRTest(unittest.TestCase): up.done() self.assertRaises(EOFError, up.unpack_uint) +class ConversionErrorTest(unittest.TestCase): + + def setUp(self): + self.packer = xdrlib.Packer() + + def assertRaisesConversion(self, *args): + self.assertRaises(xdrlib.ConversionError, *args) + + def test_pack_int(self): + self.assertRaisesConversion(self.packer.pack_int, 'string') + + def test_pack_uint(self): + self.assertRaisesConversion(self.packer.pack_uint, 'string') + + def test_float(self): + self.assertRaisesConversion(self.packer.pack_float, 'string') + + def test_double(self): + self.assertRaisesConversion(self.packer.pack_double, 'string') + + def test_uhyper(self): + self.assertRaisesConversion(self.packer.pack_uhyper, 'string') + def test_main(): support.run_unittest(XDRTest) + support.run_unittest(ConversionErrorTest) if __name__ == "__main__": test_main() |