Make unit-tests work with Python 3.5
@@ -64,7 +64,8 @@ class TestGet(ByteTester):
self._send.return_value = response
result = snmp.get('192.168.1.1', 'private', '1.3.6.1.2.1.1.2.0')
self.assertEqual(result, '1.3.6.1.4.1.8072.3.2.10')
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
if six.PY3:
self.assertIsInstance(result, str)
else:
@@ -77,7 +78,8 @@ class TestGet(ByteTester):
result = snmp.multiget('192.168.1.1', 'private', oids,
port=161, timeout=1)
self.assertEqual(result, [b'root', b'On the move'])
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
for value in result:
self.assertIsInstance(value, bytes)
@@ -88,7 +90,8 @@ class TestGet(ByteTester):
port=161, timeout=1)
expected = VarBind(OID('1.3.6.1.2.1.1.7.0'), 72)
self.assertEqual(result, expected)
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
self.assertIsInstance(result.oid, ObjectIdentifier)
self.assertIsInstance(result.value, int)
@@ -123,7 +126,8 @@ class TestGet(ByteTester):
])
)
self.assertEqual(result, expected)
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
key_types = {type(k) for k in result.listing.keys()}
if six.PY3:
@@ -171,7 +175,8 @@ class TestGet(ByteTester):
]
self.assertEqual(result, expected)
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
expected_types = [(ObjectIdentifier, datetime.timedelta)] * 10
returned_values = [(row.oid, row.value) for row in result]
assert_of_types(returned_values, expected_types)
@@ -186,7 +191,8 @@ class TestGet(ByteTester):
VarBind(OID('1.3.6.1.2.1.4.1.0'), 1)
]
self.assertEqual(result, expected)
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
expected_types = [
(ObjectIdentifier, int),
(ObjectIdentifier, int),
@@ -207,7 +213,8 @@ class TestGet(ByteTester):
'1.3.6.1.2.1.1.6.0': b'bar'
}
self.assertEqual(result, expected)
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
self.assertIsInstance(result, dict)
key_types = {type(key) for key in result.keys()}
if six.PY3:
@@ -254,7 +261,8 @@ class TestGet(ByteTester):
OctetString(b'Hello')
)
self.assertEqual(result, b'On the move')
- self._send.assert_called()
+ self.assertTrue(len(self._send.mock_calls) > 0,
+ 'method was not called!')
self.assertIsInstance(result, bytes)
def test_table(self):
