diff --git a/tests/drivers/test_impl_rabbit.py b/tests/drivers/test_impl_rabbit.py index 28737dffa..5cfa9bfaa 100644 --- a/tests/drivers/test_impl_rabbit.py +++ b/tests/drivers/test_impl_rabbit.py @@ -78,6 +78,7 @@ class TestRabbitTransportURL(test_utils.BaseTestCase): @mock.patch('oslo.messaging._drivers.impl_rabbit.Connection.ensure') def test_transport_url(self, fake_ensure): + self.messaging_conf.transport_driver = 'rabbit' self.messaging_conf.in_memory = False transport = messaging.get_transport(self.conf, self.url) diff --git a/tests/notify/test_log_handler.py b/tests/notify/test_log_handler.py index f17a28772..4e676f210 100644 --- a/tests/notify/test_log_handler.py +++ b/tests/notify/test_log_handler.py @@ -51,16 +51,8 @@ class PublishErrorsHandlerTestCase(test_utils.BaseTestCase): logrecord = logging.LogRecord(name='name', level='ERROR', pathname='/tmp', lineno=1, msg='Message', args=None, exc_info=None) - mock_init = mock.Mock(return_value=None) - with mock.patch.object(messaging.notify.notifier.Notifier, - '__init__', mock_init): - # Recreate the handler so the __init__ mock takes effect. - self.publisherrorshandler = (log_handler. - PublishErrorsHandler(logging.ERROR)) - self.publisherrorshandler.emit(logrecord) - mock_init.assert_called_with(mock.ANY, - publisher_id='error.publisher') - mock_notify.assert_called_with(None, - 'error_notification', - {'error': 'Message'}, - 'ERROR') + self.publisherrorshandler.emit(logrecord) + self.assertEqual('error.publisher', + self.publisherrorshandler._notifier.publisher_id) + mock_notify.assert_called_with(None, 'error_notification', + {'error': 'Message'}, 'ERROR') diff --git a/tests/utils.py b/tests/utils.py index 7074ff29e..886532c24 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -36,6 +36,7 @@ class BaseTestCase(base.BaseTestCase): from oslo.messaging import conffixture self.messaging_conf = self.useFixture(conffixture.ConfFixture(conf)) + self.messaging_conf.transport_driver = 'fake' self.conf = self.messaging_conf.conf moxfixture = self.useFixture(moxstubout.MoxStubout())