Back to index

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

List of all members.

Public Member Functions

def test_floats
def helper

Detailed Description

Definition at line 59 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 60 of file test_marshal.py.

00060 
00061     def test_floats(self):
00062         # Test a few floats
00063         small = 1e-25
00064         n = sys.maxsize * 3.7e250
00065         while n > small:
00066             for expected in (-n, n):
00067                 self.helper(float(expected))
00068             n /= 123.4567
00069 
00070         f = 0.0
00071         s = marshal.dumps(f, 2)
00072         got = marshal.loads(s)
00073         self.assertEqual(f, got)
00074         # and with version <= 1 (floats marshalled differently then)
00075         s = marshal.dumps(f, 1)
00076         got = marshal.loads(s)
00077         self.assertEqual(f, got)
00078 
00079         n = sys.maxsize * 3.7e-250
00080         while n < small:
00081             for expected in (-n, n):
00082                 f = float(expected)
00083                 self.helper(f)
00084                 self.helper(f, 1)
00085             n *= 123.4567

Here is the call graph for this function:


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