summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_marshal.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2005-06-03 14:41:55 (GMT)
committerMichael W. Hudson <mwh@python.net>2005-06-03 14:41:55 (GMT)
commitdf88846ebca9186514e86bc2067242233ade4608 (patch)
tree345828bee8f325fc38b74827a08f80e098dff9ea /Lib/test/test_marshal.py
parent268e61cf7458d85d2e100480635390ebd480088f (diff)
downloadcpython-df88846ebca9186514e86bc2067242233ade4608.zip
cpython-df88846ebca9186514e86bc2067242233ade4608.tar.gz
cpython-df88846ebca9186514e86bc2067242233ade4608.tar.bz2
This is my patch:
[ 1180995 ] binary formats for marshalling floats Adds 2 new type codes for marshal (binary floats and binary complexes), a new marshal version (2), updates MAGIC and fiddles the de-serializing of code objects to be less likely to clobber the real reason for failing if it fails.
Diffstat (limited to 'Lib/test/test_marshal.py')
-rw-r--r--Lib/test/test_marshal.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 9901a3c..b66eef5 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -73,20 +73,34 @@ class FloatTestCase(unittest.TestCase):
n /= 123.4567
f = 0.0
- s = marshal.dumps(f)
+ s = marshal.dumps(f, 2)
got = marshal.loads(s)
self.assertEqual(f, got)
+ # and with version <= 1 (floats marshalled differently then)
+ s = marshal.dumps(f, 1)
+ got = marshal.loads(s)
+ self.assertEqual(f, got)
n = sys.maxint * 3.7e-250
while n < small:
for expected in (-n, n):
f = float(expected)
+
s = marshal.dumps(f)
got = marshal.loads(s)
self.assertEqual(f, got)
+
+ s = marshal.dumps(f, 1)
+ got = marshal.loads(s)
+ self.assertEqual(f, got)
+
marshal.dump(f, file(test_support.TESTFN, "wb"))
got = marshal.load(file(test_support.TESTFN, "rb"))
self.assertEqual(f, got)
+
+ marshal.dump(f, file(test_support.TESTFN, "wb"), 1)
+ got = marshal.load(file(test_support.TESTFN, "rb"))
+ self.assertEqual(f, got)
n *= 123.4567
os.unlink(test_support.TESTFN)