tests: use asynctest some more
Instead of hoping normal Mock will work (which does not on Python 3.8).
This commit is contained in:
parent
3e1d36fe4a
commit
b7eca976b5
@ -22,6 +22,7 @@ import os
|
||||
import unittest.mock as mock
|
||||
|
||||
import asyncio
|
||||
import asynctest
|
||||
|
||||
import qubesadmin.tests
|
||||
import qubesadmin.tests.tools
|
||||
@ -177,9 +178,11 @@ class TC_00_qvm_backup(qubesadmin.tests.QubesTestCase):
|
||||
None)] = \
|
||||
b'0\0'
|
||||
try:
|
||||
mock_events = asynctest.CoroutineMock()
|
||||
patch = mock.patch(
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader')
|
||||
mock_events = patch.start()
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader',
|
||||
mock_events)
|
||||
patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
mock_events.side_effect = qubesadmin.tests.tools.MockEventsReader([
|
||||
b'1\0\0connection-established\0\0',
|
||||
|
@ -18,7 +18,9 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License along
|
||||
# with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
import asyncio
|
||||
import asynctest
|
||||
import unittest.mock
|
||||
|
||||
import qubesadmin.tests
|
||||
import qubesadmin.tests.tools
|
||||
import qubesadmin.tools.qvm_shutdown
|
||||
@ -85,9 +87,11 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
mock_events = asynctest.CoroutineMock()
|
||||
patch = unittest.mock.patch(
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader')
|
||||
mock_events = patch.start()
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader',
|
||||
mock_events)
|
||||
patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
mock_events.side_effect = qubesadmin.tests.tools.MockEventsReader([
|
||||
b'1\0\0connection-established\0\0',
|
||||
@ -114,9 +118,11 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
mock_events = asynctest.CoroutineMock()
|
||||
patch = unittest.mock.patch(
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader')
|
||||
mock_events = patch.start()
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader',
|
||||
mock_events)
|
||||
patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
mock_events.side_effect = qubesadmin.tests.tools.MockEventsReader([
|
||||
b'1\0\0connection-established\0\0',
|
||||
@ -159,9 +165,11 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
|
||||
loop = asyncio.new_event_loop()
|
||||
asyncio.set_event_loop(loop)
|
||||
|
||||
mock_events = asynctest.CoroutineMock()
|
||||
patch = unittest.mock.patch(
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader')
|
||||
mock_events = patch.start()
|
||||
'qubesadmin.events.EventsDispatcher._get_events_reader',
|
||||
mock_events)
|
||||
patch.start()
|
||||
self.addCleanup(patch.stop)
|
||||
mock_events.side_effect = qubesadmin.tests.tools.MockEventsReader([
|
||||
b'1\0\0connection-established\0\0',
|
||||
|
Loading…
Reference in New Issue
Block a user