Skip to content

Commit

Permalink
[Python] Use asyncio.run() to run async tests
Browse files Browse the repository at this point in the history
  • Loading branch information
agners committed Jun 20, 2024
1 parent 864519d commit b29e0cf
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 27 deletions.
4 changes: 1 addition & 3 deletions scripts/tests/chiptest/yamltest_with_chip_repl_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,4 @@ def _StackShutDown():


if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
4 changes: 1 addition & 3 deletions src/controller/python/test/test_scripts/failsafe_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ async def main():

if __name__ == "__main__":
try:
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
loop.close()
asyncio.run(main())
except Exception as ex:
logger.exception(ex)
TestFail("Exception occurred when running tests.")

0 comments on commit b29e0cf

Please sign in to comment.