Skip to content

Commit

Permalink
tests: Use socket.SOCK_STREAM in assertions
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
iv-m authored and jeffwidman committed Aug 15, 2019
1 parent ea35fdf commit 2180d31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/test_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def test_lookup_on_connect():
]
with mock.patch("socket.getaddrinfo", return_value=mock_return1) as m:
conn.connect()
m.assert_called_once_with(hostname, port, 0, 1)
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
assert conn._sock_afi == afi1
assert conn._sock_addr == sockaddr1
conn.close()
Expand All @@ -289,7 +289,7 @@ def test_lookup_on_connect():
with mock.patch("socket.getaddrinfo", return_value=mock_return2) as m:
conn.last_attempt = 0
conn.connect()
m.assert_called_once_with(hostname, port, 0, 1)
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
assert conn._sock_afi == afi2
assert conn._sock_addr == sockaddr2
conn.close()
Expand All @@ -304,7 +304,7 @@ def test_relookup_on_failure():
with mock.patch("socket.getaddrinfo", return_value=mock_return1) as m:
last_attempt = conn.last_attempt
conn.connect()
m.assert_called_once_with(hostname, port, 0, 1)
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
assert conn.disconnected()
assert conn.last_attempt > last_attempt

Expand All @@ -317,7 +317,7 @@ def test_relookup_on_failure():
with mock.patch("socket.getaddrinfo", return_value=mock_return2) as m:
conn.last_attempt = 0
conn.connect()
m.assert_called_once_with(hostname, port, 0, 1)
m.assert_called_once_with(hostname, port, 0, socket.SOCK_STREAM)
assert conn._sock_afi == afi2
assert conn._sock_addr == sockaddr2
conn.close()
Expand Down

0 comments on commit 2180d31

Please sign in to comment.