Back to index

python3.2  3.2.2
Public Member Functions
test.test_marshal.IntTestCase Class Reference
Inheritance diagram for test.test_marshal.IntTestCase:
Inheritance graph
[legend]
Collaboration diagram for test.test_marshal.IntTestCase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_ints
def test_int64
def test_bool
def helper

Detailed Description

Definition at line 22 of file test_marshal.py.


Member Function Documentation

def test.test_marshal.HelperMixin.helper (   self,
  sample,
  extra 
) [inherited]

Definition at line 10 of file test_marshal.py.

00010 
00011     def helper(self, sample, *extra):
00012         new = marshal.loads(marshal.dumps(sample, *extra))
00013         self.assertEqual(sample, new)
00014         try:
00015             with open(support.TESTFN, "wb") as f:
00016                 marshal.dump(sample, f, *extra)
00017             with open(support.TESTFN, "rb") as f:
00018                 new = marshal.load(f)
00019             self.assertEqual(sample, new)
00020         finally:
00021             support.unlink(support.TESTFN)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 55 of file test_marshal.py.

00055 
00056     def test_bool(self):
00057         for b in (True, False):
00058             self.helper(b)

Here is the call graph for this function:

Definition at line 31 of file test_marshal.py.

00031 
00032     def test_int64(self):
00033         # Simulate int marshaling on a 64-bit box.  This is most interesting if
00034         # we're running the test on a 32-bit box, of course.
00035 
00036         def to_little_endian_string(value, nbytes):
00037             b = bytearray()
00038             for i in range(nbytes):
00039                 b.append(value & 0xff)
00040                 value >>= 8
00041             return b
00042 
00043         maxint64 = (1 << 63) - 1
00044         minint64 = -maxint64-1
00045 
00046         for base in maxint64, minint64, -maxint64, -(minint64 >> 1):
00047             while base:
00048                 s = b'I' + to_little_endian_string(base, 8)
00049                 got = marshal.loads(s)
00050                 self.assertEqual(base, got)
00051                 if base == -1:  # a fixed-point for shifting right 1
00052                     base = 0
00053                 else:
00054                     base >>= 1

Here is the call graph for this function:

Definition at line 23 of file test_marshal.py.

00023 
00024     def test_ints(self):
00025         # Test the full range of Python ints.
00026         n = sys.maxsize
00027         while n:
00028             for expected in (-n, n):
00029                 self.helper(expected)
00030             n = n >> 1

Here is the call graph for this function:


The documentation for this class was generated from the following file: