Skip to content

Commit 606af35

Browse files
tests/test_ethernetport: create and set event loop for test
Calling asyncio.get_event_loop() with no current event loop is deprecated since Python 3.10 and will be an error in some future Python release [1]. SNMPEthernetPort expects a running event loop. So create and set one. [1] https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.get_event_loop Signed-off-by: Bastian Krause <[email protected]>
1 parent 37a92b5 commit 606af35

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/test_ethernetport.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
import asyncio
2+
13
from labgrid.resource import SNMPEthernetPort
24

35

46
def test_instance(target):
5-
s = SNMPEthernetPort(target, 'port-1', switch='dummy-switch', interface='1')
6-
assert (isinstance(s, SNMPEthernetPort))
7+
# SNMPEthernetPort should be called with a running event loop
8+
loop = asyncio.new_event_loop()
9+
asyncio.set_event_loop(loop)
10+
11+
try:
12+
s = SNMPEthernetPort(target, 'port-1', switch='dummy-switch', interface='1')
13+
assert (isinstance(s, SNMPEthernetPort))
14+
finally:
15+
loop.close()

0 commit comments

Comments
 (0)