[pypy-commit] pypy py3k-struct: Add a small struct test that was also failing from the buildbot for python 3
Jason Chu
noreply at buildbot.pypy.org
Wed Mar 20 01:02:06 CET 2013
Author: Jason Chu <jason.chu at yougov.com>
Branch: py3k-struct
Changeset: r62519:ee2033fb01d1
Date: 2013-03-19 15:57 -0700
http://bitbucket.org/pypy/pypy/changeset/ee2033fb01d1/
Log: Add a small struct test that was also failing from the buildbot for
python 3
diff --git a/pypy/module/struct/test/test_struct.py b/pypy/module/struct/test/test_struct.py
--- a/pypy/module/struct/test/test_struct.py
+++ b/pypy/module/struct/test/test_struct.py
@@ -422,6 +422,35 @@
raises(self.struct.error, self.struct.pack, 'P', 1.0)
raises(self.struct.error, self.struct.pack, 'P', 1.5)
+ def test_integers(self):
+ # Native 'q' packing isn't available on systems that don't have the C
+ # long long type.
+ try:
+ self.struct.pack('q', 5)
+ except self.struct.error:
+ HAVE_LONG_LONG = False
+ else:
+ HAVE_LONG_LONG = True
+
+ integer_codes = ('b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q')
+ byteorders = '', '@', '=', '<', '>', '!'
+
+ def run_not_int_test(format):
+ class NotAnInt:
+ def __int__(self):
+ return 42
+ raises((TypeError, self.struct.error),
+ self.struct.pack, format,
+ NotAnInt())
+
+ for code in integer_codes:
+ for byteorder in byteorders:
+ if (byteorder in ('', '@') and code in ('q', 'Q') and
+ not HAVE_LONG_LONG):
+ continue
+ format = byteorder+code
+ t = run_not_int_test(format)
+
class AppTestStructBuffer(object):
spaceconfig = dict(usemodules=['struct', '__pypy__'])
More information about the pypy-commit
mailing list