Replace assertRaisesRegexp with assertRaisesRegex

This replaces the deprecated (in python 3.2) unittest.TestCase
method assertRaisesRegexp() with assertRaisesRegex()

Change-Id: I98945eeb3e432b9b63deeaeac193585a601b671e
This commit is contained in:
M V P Nitesh 2017-05-19 15:57:14 +05:30
parent 851b075b6e
commit ec6a695a32
5 changed files with 22 additions and 22 deletions

View File

@ -169,8 +169,8 @@ class TestHealthDaemon(base.TestCase):
mock_build_msg.side_effect = ['TEST', Exception('break')]
test_queue = queue.Queue()
self.assertRaisesRegexp(Exception, 'break',
health_daemon.run_sender, test_queue)
self.assertRaisesRegex(Exception, 'break',
health_daemon.run_sender, test_queue)
sender_mock.dosend.assert_called_once_with('TEST')
@ -178,8 +178,8 @@ class TestHealthDaemon(base.TestCase):
mock_build_msg.reset_mock()
mock_build_msg.side_effect = ['TEST', Exception('break')]
test_queue.put('reload')
self.assertRaisesRegexp(Exception, 'break',
health_daemon.run_sender, test_queue)
self.assertRaisesRegex(Exception, 'break',
health_daemon.run_sender, test_queue)
mock_reload_cfg.assert_called_once_with()
# Test the shutdown path
@ -195,8 +195,8 @@ class TestHealthDaemon(base.TestCase):
mock_build_msg.reset_mock()
mock_build_msg.side_effect = ['TEST', Exception('break')]
test_queue.put('bogus')
self.assertRaisesRegexp(Exception, 'break',
health_daemon.run_sender, test_queue)
self.assertRaisesRegex(Exception, 'break',
health_daemon.run_sender, test_queue)
@mock.patch('octavia.amphorae.backends.utils.haproxy_query.HAProxyQuery')
def test_get_stats(self, mock_query):

View File

@ -80,9 +80,9 @@ class QueryTestCase(base.TestCase):
sock.recv.assert_called_with(1024)
self.assertTrue(sock.close.called)
self.assertRaisesRegexp(Exception,
'HAProxy \'test\' query failed.',
self.q._query, 'test')
self.assertRaisesRegex(Exception,
'HAProxy \'test\' query failed.',
self.q._query, 'test')
def test_get_pool_status(self):
query_mock = mock.Mock()

View File

@ -31,9 +31,9 @@ class TestHAproxyVRRPCheckCMD(base.TestCase):
recv_mock.side_effect = [b'1', Exception('BREAK')]
socket_mock.recv = recv_mock
self.assertRaisesRegexp(Exception, 'BREAK',
haproxy_vrrp_check.health_check,
'10.0.0.1')
self.assertRaisesRegex(Exception, 'BREAK',
haproxy_vrrp_check.health_check,
'10.0.0.1')
@mock.patch('octavia.cmd.haproxy_vrrp_check.health_check')
@mock.patch('sys.argv')

View File

@ -35,8 +35,8 @@ class TestHealthManagerCMD(base.TestCase):
getter_mock.check = check_mock
getter_mock.check.side_effect = [None, Exception('break')]
mock_getter.return_value = getter_mock
self.assertRaisesRegexp(Exception, 'break',
health_manager.hm_listener)
self.assertRaisesRegex(Exception, 'break',
health_manager.hm_listener)
mock_getter.assert_called_once_with(mock_health(), mock_stats())
self.assertEqual(2, getter_mock.check.call_count)
@ -48,8 +48,8 @@ class TestHealthManagerCMD(base.TestCase):
hm_mock.health_check = health_check_mock
hm_mock.health_check.side_effect = [None, Exception('break')]
mock_health.return_value = hm_mock
self.assertRaisesRegexp(Exception, 'break',
health_manager.hm_health_check)
self.assertRaisesRegex(Exception, 'break',
health_manager.hm_health_check)
mock_health.assert_called_once_with()
self.assertEqual(2, hm_mock.health_check.call_count)

View File

@ -37,8 +37,8 @@ class TestHouseKeepingCMD(base.TestCase):
spare_amp_thread_event_mock.is_set.side_effect = [False,
Exception('break')]
self.assertRaisesRegexp(Exception, 'break',
house_keeping.spare_amphora_check)
self.assertRaisesRegex(Exception, 'break',
house_keeping.spare_amphora_check)
mock_SpareAmphora.assert_called_once_with()
self.assertEqual(1, spare_amp_mock.spare_check.call_count)
@ -57,7 +57,7 @@ class TestHouseKeepingCMD(base.TestCase):
db_cleanup_event_mock.is_set = mock.MagicMock()
db_cleanup_event_mock.is_set.side_effect = [False, Exception('break')]
self.assertRaisesRegexp(Exception, 'break', house_keeping.db_cleanup)
self.assertRaisesRegex(Exception, 'break', house_keeping.db_cleanup)
mock_DatabaseCleanup.assert_called_once_with()
self.assertEqual(1, db_cleanup.delete_old_amphorae.call_count)
@ -80,8 +80,8 @@ class TestHouseKeepingCMD(base.TestCase):
cert_rotate_event_mock.is_set = mock.MagicMock()
cert_rotate_event_mock.is_set.side_effect = [False, Exception('break')]
self.assertRaisesRegexp(Exception, 'break',
house_keeping.cert_rotation)
self.assertRaisesRegex(Exception, 'break',
house_keeping.cert_rotation)
mock_CertRotation.assert_called_once_with()
self.assertEqual(1, cert_rotate_mock.rotate.call_count)
@ -134,7 +134,7 @@ class TestHouseKeepingCMD(base.TestCase):
# mock the time.sleep() in the while loop
sleep_time.side_effect = [True, Exception('break')]
self.assertRaisesRegexp(Exception, 'break', house_keeping.main)
self.assertRaisesRegex(Exception, 'break', house_keeping.main)
spare_amp_thread_mock.start.assert_called_once_with()
db_cleanup_thread_mock.start.assert_called_once_with()