diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-25 05:44:03 +0000 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-01-25 05:44:03 +0000 |
commit | 8ce491aef25ed06c61d83daa4a2dd19599243c6a (patch) | |
tree | c103ce2a65ca330d4baaa4b15a19cb70d120cc16 | |
parent | 3f1b53d85bb53f1f0c049deda310296aa2242098 (diff) | |
download | psutil-8ce491aef25ed06c61d83daa4a2dd19599243c6a.tar.gz |
try to fix test
-rw-r--r-- | psutil/_psutil_osx.c | 1 | ||||
-rwxr-xr-x | psutil/tests/test_connections.py | 12 |
2 files changed, 10 insertions, 3 deletions
diff --git a/psutil/_psutil_osx.c b/psutil/_psutil_osx.c index 1141fff9..85c694d8 100644 --- a/psutil/_psutil_osx.c +++ b/psutil/_psutil_osx.c @@ -1836,7 +1836,6 @@ static PyMethodDef mod_methods[] = { void init_psutil_osx(void) #endif /* PY_MAJOR_VERSION */ { - PyObject *v; #if PY_MAJOR_VERSION >= 3 PyObject *mod = PyModule_Create(&moduledef); #else diff --git a/psutil/tests/test_connections.py b/psutil/tests/test_connections.py index b7f3a52b..93d8473a 100755 --- a/psutil/tests/test_connections.py +++ b/psutil/tests/test_connections.py @@ -191,8 +191,16 @@ class TestUnconnectedSockets(Base, unittest.TestCase): def get_conn_from_sock(self, sock): cons = thisproc.connections(kind='all') - smap = dict([(c.fd, c) for c in cons]) - return smap[sock.fileno()] + if NETBSD or FREEBSD: + # NetBSD opens a UNIX socket to /var/log/run + # so there may be more connections. + smap = dict([(c.fd, c) for c in cons]) + return smap[sock.fileno()] + else: + self.assertEqual(len(cons), 1) + if cons[0].fd != -1: + self.assertEqual(smap[sock.fileno()].fd, sock.fileno()) + return cons[0] def check_socket(self, sock): """Given a socket, makes sure it matches the one obtained |