Skip to content

Commit

Permalink
tests/test_ethernetport: create and set event loop for test
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Bastian-Krause committed Aug 1, 2024
1 parent df2c0eb commit f865475
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tests/test_ethernetport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import asyncio

from labgrid.resource import SNMPEthernetPort


def test_instance(target):
s = SNMPEthernetPort(target, 'port-1', switch='dummy-switch', interface='1')
assert (isinstance(s, SNMPEthernetPort))
# SNMPEthernetPort should be called with a running event loop
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)

try:
s = SNMPEthernetPort(target, 'port-1', switch='dummy-switch', interface='1')
assert (isinstance(s, SNMPEthernetPort))
finally:
loop.close()

0 comments on commit f865475

Please sign in to comment.