diff options
author | Mark W. Eichin <eichin@thok.org> | 2009-04-24 05:21:41 +0000 |
---|---|---|
committer | Mark W. Eichin <eichin@thok.org> | 2009-04-24 05:21:41 +0000 |
commit | d82e67f2eb756e1e2e8b7c19630dd4a2d6aeaa17 (patch) | |
tree | ddd90e8687751562cb57f7b9a469423b0ae1b9c6 /lib/zephyr_tests.txt | |
parent | aa706b41aba93656194347be6cddd9601a286925 (diff) |
test that the file descriptor ZGetFD returns is actually a socket
Diffstat (limited to 'lib/zephyr_tests.txt')
-rw-r--r-- | lib/zephyr_tests.txt | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/zephyr_tests.txt b/lib/zephyr_tests.txt index 906399a..a30cb88 100644 --- a/lib/zephyr_tests.txt +++ b/lib/zephyr_tests.txt @@ -176,6 +176,17 @@ Trivial test of ZOpenPort and ZClosePort: >>> st = _z.ZOpenPort(port) >>> assert st == 0 >>> assert _z.ZGetFD() != -1 + >>> zsock = zephyr_tests.getsockname(_z.ZGetFD()) + >>> assert zsock + >>> from socket import AF_INET + >>> assert zsock.sa_family.value == AF_INET, zsock.sa_family + +(Here we're actually using getsockname as an "is that file descriptor + a socket" test; the wrapper is weak in that it can't check for + ENOTSOCK without requiring Python 2.6, so it just throws an exception + on any return of -1. If ctypes.cast worked on sockaddr, we could + also cast it to sockaddr_in and look at the address and port...) + >>> assert port != 0 >>> zephyr_tests.ctypes_pprint(_z.ZGetDestAddr()) ... # doctest: +ELLIPSIS @@ -184,8 +195,6 @@ Trivial test of ZOpenPort and ZClosePort: sin_addr 127.0.0.1 sin_zero [ignored] -TODO: consider checking that ZGetFD is returning a socket on that port. - >>> assert _z.ZClosePort() == 0 >>> assert _z.ZGetFD() == -1 |