Skip to content

Commit

Permalink
Fix test and tox configuration.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoclawski committed May 28, 2024
1 parent 4c44411 commit 0b05712
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
22 changes: 12 additions & 10 deletions tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,25 @@ def test_socket(self):

class TestGetSocket(TestCase):
@mock.patch('socket.create_connection')
def test_with_interrupt(self, socket_build):
connect = socket_build.return_value.connect
connect.side_effect = [
def test_with_interrupt(self, create_connection_mock):
create_connection_mock.side_effect = [
socket.error(api_socket.EINTR),
None
mock.Mock(),
]
api_socket.get_socket('host', 123)
connect.assert_has_calls([mock.call(('host', 123)),
mock.call(('host', 123))])
create_connection_mock.assert_has_calls([
mock.call(('host', 123), timeout=15.0),
mock.call(('host', 123), timeout=15.0),
])

@mock.patch('socket.create_connection')
def test_with_other_error(self, socket_build):
connect = socket_build.return_value.connect
connect.side_effect = [
def test_with_other_error(self, create_connection_mock):
create_connection_mock.side_effect = [
socket.error(1),
None
]
self.assertRaises(exceptions.RouterOsApiConnectionError,
api_socket.get_socket, 'host', 123)
connect.assert_has_calls([mock.call(('host', 123))])
create_connection_mock.assert_has_calls([
mock.call(('host', 123), timeout=15.0),
])
7 changes: 6 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[tox]
envlist = py39,py310,py311,py312
requires = tox>=4
env_list = py{39,310,311,312}

[testenv]
description = run unit tests
commands = python -m unittest

0 comments on commit 0b05712

Please sign in to comment.