Commits

Armin Rigo committed 40b08dc

Fix tests for windows.

  • Participants
  • Parent commits 6b57fdf

Comments (0)

Files changed (3)

testing/test_function.py

 import py
 from cffi import FFI
-import math, os
+import math, os, sys
 from cffi.backend_ctypes import CTypesBackend
 
 
         assert x == math.sin(1.23)
 
     def test_sinf(self):
+        if sys.platform == 'win32':
+            py.test.skip("no 'sinf'")
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""
             float sinf(float x);
         assert res == 'hello\n  world\n'
 
     def test_fputs(self):
+        if sys.platform == 'win32':
+            py.test.skip("no 'stderr'")
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""
             int fputs(const char *, void *);
             ffi.C.printf("hello %p\n", None)
             ffi.C.fflush(None)
         res = fd.getvalue()
+        if sys.platform == 'win32':
+            NIL = "00000000"
+        else:
+            NIL = "(nil)"
         assert res == ("hello with no arguments\n"
                        "hello, world!\n"
                        "hello, world2!\n"
                        "hello int 42 long 84 long long 168\n"
-                       "hello (nil)\n")
+                       "hello " + NIL + "\n")
 
     def test_must_specify_type_of_vararg(self):
         ffi = FFI(backend=self.Backend())
         assert res == 5
 
     def test_write_variable(self):
+        if sys.platform == 'win32':
+            py.test.skip("no 'stdout'")
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""
             int puts(const char *);
         assert str(q) == "world!"
 
     def test_function_with_struct_argument(self):
+        if sys.platform == 'win32':
+            py.test.skip("no 'inet_ntoa'")
         ffi = FFI(backend=self.Backend())
         ffi.cdef("""
             struct in_addr { unsigned int s_addr; };

testing/test_parsing.py

-import py
+import py, sys
 from cffi import FFI, CDefError
 
 class FakeBackend(object):
         return 1
 
     def load_library(self, name):
-        assert "libc" in name or "libm" in name
+        if sys.platform == 'win32':
+            assert "msvcr" in name
+        else:
+            assert "libc" in name or "libm" in name
         return FakeLibrary()
 
     def new_function_type(self, args, result, has_varargs):

testing/test_verify.py

 import py
-import math
+import sys, math
 from cffi import FFI, VerificationError, VerificationMissing, model
 
 
-class FFI(FFI):
-    def verify(self, *args, **kwds):
-        # XXX a GCC-only way to say "crash upon warnings too"
-        return super(FFI, self).verify(*args, extra_compile_args=['-Werror'],
-                                       **kwds)
+if sys.platform != 'win32':
+    class FFI(FFI):
+        def verify(self, *args, **kwds):
+            # XXX a GCC-only way to say "crash upon warnings too"
+            return super(FFI, self).verify(
+                *args, extra_compile_args=['-Werror'], **kwds)
 
 
 def test_missing_function():