Skip to content

Commit 2180d31

Browse files
iv-mjeffwidman
authored andcommitted
tests: Use socket.SOCK_STREAM in assertions
socket.SOCK_STREAM is platform specific and on some platforms (most notably on Linux on MIPS) does not equal 1; so it's better to use the constant where appropriate. This change fixes the tests on my MIPS32 LE machine. Signed-off-by: Ivan A. Melnikov <iv@altlinux.org>
1 parent ea35fdf commit 2180d31

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/test_conn.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ def test_lookup_on_connect():
275275
]
276276
with mock.patch("socket.getaddrinfo", return_value=mock_return1) as m:
277277
conn.connect()
278-
m.assert_called_once_with(hostname, port, 0, 1)
278+
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
279279
assert conn._sock_afi == afi1
280280
assert conn._sock_addr == sockaddr1
281281
conn.close()
@@ -289,7 +289,7 @@ def test_lookup_on_connect():
289289
with mock.patch("socket.getaddrinfo", return_value=mock_return2) as m:
290290
conn.last_attempt = 0
291291
conn.connect()
292-
m.assert_called_once_with(hostname, port, 0, 1)
292+
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
293293
assert conn._sock_afi == afi2
294294
assert conn._sock_addr == sockaddr2
295295
conn.close()
@@ -304,7 +304,7 @@ def test_relookup_on_failure():
304304
with mock.patch("socket.getaddrinfo", return_value=mock_return1) as m:
305305
last_attempt = conn.last_attempt
306306
conn.connect()
307-
m.assert_called_once_with(hostname, port, 0, 1)
307+
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
308308
assert conn.disconnected()
309309
assert conn.last_attempt > last_attempt
310310

@@ -317,7 +317,7 @@ def test_relookup_on_failure():
317317
with mock.patch("socket.getaddrinfo", return_value=mock_return2) as m:
318318
conn.last_attempt = 0
319319
conn.connect()
320-
m.assert_called_once_with(hostname, port, 0, 1)
320+
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
321321
assert conn._sock_afi == afi2
322322
assert conn._sock_addr == sockaddr2
323323
conn.close()

0 commit comments

Comments
 (0)