@@ -39,7 +39,8 @@ def async_test(f):
3939 def wrapper (* args , ** kwargs ):
4040 coro = asyncio .coroutine (f )
4141 future = coro (* args , ** kwargs )
42- loop = asyncio .get_event_loop ()
42+ loop = asyncio .new_event_loop ()
43+ asyncio .set_event_loop (loop )
4344 loop .run_until_complete (future )
4445
4546 return wrapper
@@ -1124,9 +1125,8 @@ def test_071_failed_confirmation(self, socket):
11241125
11251126 socket .return_value = "allow:nonsense"
11261127
1127- loop = asyncio .get_event_loop ()
11281128 self .ext .attach_and_notify = AsyncMock ()
1129- loop . run_until_complete (
1129+ asyncio . run (
11301130 qubes .ext .utils .resolve_conflicts_and_attach (
11311131 self .ext , {"sda" : {front : assign , back : assign }}
11321132 )
@@ -1149,9 +1149,8 @@ def test_072_successful_confirmation(self, socket):
11491149
11501150 socket .return_value = "allow:front-vm"
11511151
1152- loop = asyncio .get_event_loop ()
11531152 self .ext .attach_and_notify = AsyncMock ()
1154- loop . run_until_complete (
1153+ asyncio . run (
11551154 qubes .ext .utils .resolve_conflicts_and_attach (
11561155 self .ext , {"sda" : {front : assign , back : assign }}
11571156 )
@@ -1203,10 +1202,9 @@ def test_080_on_startup_multiple_assignments_including_full(self):
12031202 )
12041203
12051204 self .ext .attach_and_notify = Mock ()
1206- loop = asyncio .get_event_loop ()
12071205 with mock .patch ("asyncio.wait" ):
12081206 with mock .patch ("asyncio.ensure_future" ):
1209- loop . run_until_complete (self .ext .on_domain_start (front , None ))
1207+ asyncio . run (self .ext .on_domain_start (front , None ))
12101208 self .assertEqual (
12111209 self .ext .attach_and_notify .call_args [0 ][1 ].options , {"pid" : "did" }
12121210 )
@@ -1235,10 +1233,9 @@ def test_081_on_startup_multiple_assignments_port_vs_dev(self):
12351233 )
12361234
12371235 self .ext .attach_and_notify = Mock ()
1238- loop = asyncio .get_event_loop ()
12391236 with mock .patch ("asyncio.wait" ):
12401237 with mock .patch ("asyncio.ensure_future" ):
1241- loop . run_until_complete (self .ext .on_domain_start (front , None ))
1238+ asyncio . run (self .ext .on_domain_start (front , None ))
12421239 self .assertEqual (
12431240 self .ext .attach_and_notify .call_args [0 ][1 ].options , {"pid" : "any" }
12441241 )
@@ -1270,10 +1267,9 @@ def test_082_on_startup_multiple_assignments_dev(self):
12701267 )
12711268
12721269 self .ext .attach_and_notify = Mock ()
1273- loop = asyncio .get_event_loop ()
12741270 with mock .patch ("asyncio.wait" ):
12751271 with mock .patch ("asyncio.ensure_future" ):
1276- loop . run_until_complete (self .ext .on_domain_start (front , None ))
1272+ asyncio . run (self .ext .on_domain_start (front , None ))
12771273 self .assertEqual (
12781274 self .ext .attach_and_notify .call_args [0 ][1 ].options , {"any" : "did" }
12791275 )
@@ -1299,7 +1295,6 @@ def test_083_on_startup_already_attached(self):
12991295 back .devices ["block" ]._exposed .append (exp_dev )
13001296
13011297 self .ext .attach_and_notify = Mock ()
1302- loop = asyncio .get_event_loop ()
13031298 with mock .patch ("asyncio.ensure_future" ):
1304- loop . run_until_complete (self .ext .on_domain_start (front , None ))
1299+ asyncio . run (self .ext .on_domain_start (front , None ))
13051300 self .ext .attach_and_notify .assert_not_called ()
0 commit comments