From 9a2ba5e7fb7921df43d41f56cb208a31df2d37f5 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Tue, 12 Mar 2019 15:47:43 -0500 Subject: [PATCH] Mock Thread for both connection tests With one of the tests having a mocked Thread, self.conn.Poller sometimes showed up as mocked, sometimes not in test_start() Co-authored-by: Lucas Alvares Gomes Change-Id: Ifc3b532ec522368340aa94dc598802132577958e --- ovsdbapp/tests/unit/backend/ovs_idl/test_connection.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ovsdbapp/tests/unit/backend/ovs_idl/test_connection.py b/ovsdbapp/tests/unit/backend/ovs_idl/test_connection.py index 987dee79..4d1e415b 100644 --- a/ovsdbapp/tests/unit/backend/ovs_idl/test_connection.py +++ b/ovsdbapp/tests/unit/backend/ovs_idl/test_connection.py @@ -13,7 +13,6 @@ # under the License. import mock -import threading from ovs import poller @@ -22,6 +21,7 @@ from ovsdbapp.backend.ovs_idl import idlutils from ovsdbapp.tests import base +@mock.patch.object(connection.threading, 'Thread') class TestOVSNativeConnection(base.TestCase): @mock.patch.object(connection, 'TransactionQueue') @@ -32,7 +32,6 @@ class TestOVSNativeConnection(base.TestCase): self.conn = connection.Connection(self.idl, timeout=1) self.mock_trans_queue.assert_called_once_with(1) - @mock.patch.object(threading, 'Thread') @mock.patch.object(poller, 'Poller') @mock.patch.object(idlutils, 'wait_for_change') def test_start(self, mock_wait_for_change, mock_poller, mock_thread): @@ -46,7 +45,7 @@ class TestOVSNativeConnection(base.TestCase): mock_thread.return_value.setDaemon.assert_called_once_with(True) mock_thread.return_value.start.assert_called_once_with() - def test_queue_txn(self): + def test_queue_txn(self, mock_thread): self.conn.start() self.conn.queue_txn('blah') self.conn.txns.put.assert_called_once_with('blah',