[pypy-svn] r61727 - pypy/trunk/pypy/module/_rawffi/test

afa at codespeak.net afa at codespeak.net
Wed Feb 11 14:23:19 CET 2009


Author: afa
Date: Wed Feb 11 14:23:19 2009
New Revision: 61727

Modified:
   pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py
Log:
Avoid "import plaform" at applevel: this module has too many dependencies and is very slow.
Compute the result (isx86_64) before and make it an applevel constant.


Modified: pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py	(original)
+++ pypy/trunk/pypy/module/_rawffi/test/test__rawffi.py	Wed Feb 11 14:23:19 2009
@@ -172,6 +172,8 @@
             cls.w_libm_name = space.wrap('libm.so')
             if sys.platform == "darwin":
                 cls.w_libm_name = space.wrap('libm.dylib')
+        import platform
+        cls.w_isx86_64 = space.wrap(platform.machine() == 'x86_64')
                 
         cls.w_sizes_and_alignments = space.wrap(dict(
             [(k, (v.c_size, v.c_alignment)) for k,v in TYPEMAP.iteritems()]))
@@ -735,12 +737,13 @@
         raises(_rawffi.SegfaultException, a.__setitem__, 3, 3)
 
     def test_struct_byvalue(self):
-        import _rawffi, platform
-        if platform.machine() == 'x86_64':
+        import _rawffi
+        if self.isx86_64:
             skip("Segfaults on x86_64 because small structures "
                  "may be passed in registers and "
                  "c_elements must not be null")
 
+        import _rawffi
         X_Y = _rawffi.Structure([('x', 'l'), ('y', 'l')])
         x_y = X_Y()
         lib = _rawffi.CDLL(self.lib_name)
@@ -752,12 +755,12 @@
         x_y.free()
 
     def test_ret_struct(self):
-        import _rawffi, platform
-        if platform.machine() == 'x86_64':
+        if self.isx86_64:
             skip("Segfaults on x86_64 because small structures "
                  "may be passed in registers and "
                  "c_elements must not be null")
 
+        import _rawffi
         S2H = _rawffi.Structure([('x', 'h'), ('y', 'h')])
         s2h = S2H()
         lib = _rawffi.CDLL(self.lib_name)



More information about the Pypy-commit mailing list