Author: Brian Kearns <[email protected]>
Branch: 
Changeset: r62679:7d54c7b1e3de
Date: 2013-03-23 01:52 +0100
http://bitbucket.org/pypy/pypy/changeset/7d54c7b1e3de/

Log:    fix gethostbyaddr tests for when ipv6 is not available

diff --git a/pypy/module/_socket/test/test_sock_app.py 
b/pypy/module/_socket/test/test_sock_app.py
--- a/pypy/module/_socket/test/test_sock_app.py
+++ b/pypy/module/_socket/test/test_sock_app.py
@@ -32,7 +32,19 @@
         assert space.unwrap(ip) == socket.gethostbyname_ex(host)
 
 def test_gethostbyaddr():
+    try:
+        socket.gethostbyaddr("::1")
+    except socket.herror:
+        ipv6 = False
+    else:
+        ipv6 = True
     for host in ["localhost", "127.0.0.1", "::1"]:
+        if host == "::1" and not ipv6:
+            from pypy.interpreter.error import OperationError
+            with py.test.raises(OperationError):
+                space.appexec([w_socket, space.wrap(host)],
+                              "(_socket, host): return 
_socket.gethostbyaddr(host)")
+            continue
         ip = space.appexec([w_socket, space.wrap(host)],
                            "(_socket, host): return 
_socket.gethostbyaddr(host)")
         assert space.unwrap(ip) == socket.gethostbyaddr(host)
diff --git a/rpython/rlib/test/test_rsocket.py 
b/rpython/rlib/test/test_rsocket.py
--- a/rpython/rlib/test/test_rsocket.py
+++ b/rpython/rlib/test/test_rsocket.py
@@ -68,7 +68,17 @@
                          % (address_list,))
 
 def test_gethostbyaddr():
+    try:
+        cpy_socket.gethostbyaddr("::1")
+    except cpy_socket.herror:
+        ipv6 = False
+    else:
+        ipv6 = True
     for host in ["localhost", "127.0.0.1", "::1"]:
+        if host == "::1" and not ipv6:
+            with py.test.raises(HSocketError):
+                gethostbyaddr(host)
+            continue
         name, aliases, address_list = gethostbyaddr(host)
         allnames = [name] + aliases
         for n in allnames:
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to