Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(73423)

Side by Side Diff: Lib/test/test_xdrlib.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_with.py ('k') | Lib/test/test_xmlrpc.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 from test import support 1 from test import support
2 import unittest 2 import unittest
3 3
4 import xdrlib 4 import xdrlib
5 5
6 class XDRTest(unittest.TestCase): 6 class XDRTest(unittest.TestCase):
7 7
8 def test_xdr(self): 8 def test_xdr(self):
9 p = xdrlib.Packer() 9 p = xdrlib.Packer()
10 10
(...skipping 14 matching lines...) Expand all
25 25
26 # now verify 26 # now verify
27 data = p.get_buffer() 27 data = p.get_buffer()
28 up = xdrlib.Unpacker(data) 28 up = xdrlib.Unpacker(data)
29 29
30 self.assertEqual(up.get_position(), 0) 30 self.assertEqual(up.get_position(), 0)
31 31
32 self.assertEqual(up.unpack_int(), 42) 32 self.assertEqual(up.unpack_int(), 42)
33 self.assertEqual(up.unpack_int(), -17) 33 self.assertEqual(up.unpack_int(), -17)
34 self.assertEqual(up.unpack_uint(), 9) 34 self.assertEqual(up.unpack_uint(), 9)
35 self.assertTrue(up.unpack_bool() is True) 35 self.assertIs(up.unpack_bool(), True)
36 36
37 # remember position 37 # remember position
38 pos = up.get_position() 38 pos = up.get_position()
39 self.assertTrue(up.unpack_bool() is False) 39 self.assertIs(up.unpack_bool(), False)
40 40
41 # rewind and unpack again 41 # rewind and unpack again
42 up.set_position(pos) 42 up.set_position(pos)
43 self.assertTrue(up.unpack_bool() is False) 43 self.assertIs(up.unpack_bool(), False)
44 44
45 self.assertEqual(up.unpack_uhyper(), 45) 45 self.assertEqual(up.unpack_uhyper(), 45)
46 self.assertAlmostEqual(up.unpack_float(), 1.9) 46 self.assertAlmostEqual(up.unpack_float(), 1.9)
47 self.assertAlmostEqual(up.unpack_double(), 1.9) 47 self.assertAlmostEqual(up.unpack_double(), 1.9)
48 self.assertEqual(up.unpack_string(), s) 48 self.assertEqual(up.unpack_string(), s)
49 self.assertEqual(up.unpack_list(up.unpack_uint), list(range(5))) 49 self.assertEqual(up.unpack_list(up.unpack_uint), list(range(5)))
50 self.assertEqual(up.unpack_array(up.unpack_string), a) 50 self.assertEqual(up.unpack_array(up.unpack_string), a)
51 up.done() 51 up.done()
52 self.assertRaises(EOFError, up.unpack_uint) 52 self.assertRaises(EOFError, up.unpack_uint)
53 53
54 def test_main(): 54 def test_main():
55 support.run_unittest(XDRTest) 55 support.run_unittest(XDRTest)
56 56
57 if __name__ == "__main__": 57 if __name__ == "__main__":
58 test_main() 58 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_with.py ('k') | Lib/test/test_xmlrpc.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+