Skip to content

Commit b29e0cf

Browse files
committed
[Python] Use asyncio.run() to run async tests
1 parent 864519d commit b29e0cf

9 files changed

+9
-27
lines changed

scripts/tests/chiptest/yamltest_with_chip_repl_tester.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,4 @@ def _StackShutDown():
153153

154154

155155
if __name__ == '__main__':
156-
loop = asyncio.get_event_loop()
157-
loop.run_until_complete(main())
158-
loop.close()
156+
asyncio.run(main())

src/controller/python/test/test_scripts/commissioning_failure_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ async def main():
136136

137137
if __name__ == "__main__":
138138
try:
139-
loop = asyncio.get_event_loop()
140-
loop.run_until_complete(main())
141-
loop.close()
139+
asyncio.run(main())
142140
except Exception as ex:
143141
logger.exception(ex)
144142
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/commissioning_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,7 @@ async def main():
164164

165165
if __name__ == "__main__":
166166
try:
167-
loop = asyncio.get_event_loop()
168-
loop.run_until_complete(main())
169-
loop.close()
167+
asyncio.run(main())
170168
except Exception as ex:
171169
logger.exception(ex)
172170
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/failsafe_tests.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ async def main():
113113

114114
if __name__ == "__main__":
115115
try:
116-
loop = asyncio.get_event_loop()
117-
loop.run_until_complete(main())
118-
loop.close()
116+
asyncio.run(main())
119117
except Exception as ex:
120118
logger.exception(ex)
121119
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/split_commissioning_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ async def main():
137137

138138
if __name__ == "__main__":
139139
try:
140-
loop = asyncio.get_event_loop()
141-
loop.run_until_complete(main())
142-
loop.close()
140+
asyncio.run(main())
143141
except Exception as ex:
144142
logger.exception(ex)
145143
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl1.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ async def main():
129129

130130
if __name__ == "__main__":
131131
try:
132-
loop = asyncio.get_event_loop()
133-
loop.run_until_complete(main())
134-
loop.close()
132+
asyncio.run(main())
135133
except Exception as ex:
136134
logger.exception(ex)
137135
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/subscription_resumption_capacity_test_ctrl2.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,7 @@ async def main():
141141

142142
if __name__ == "__main__":
143143
try:
144-
loop = asyncio.get_event_loop()
145-
loop.run_until_complete(main())
146-
loop.close()
144+
asyncio.run(main())
147145
except Exception as ex:
148146
logger.exception(ex)
149147
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/subscription_resumption_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@ async def main():
130130

131131
if __name__ == "__main__":
132132
try:
133-
loop = asyncio.get_event_loop()
134-
loop.run_until_complete(main())
135-
loop.close()
133+
asyncio.run(main())
136134
except Exception as ex:
137135
logger.exception(ex)
138136
TestFail("Exception occurred when running tests.")

src/controller/python/test/test_scripts/subscription_resumption_timeout_test.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ async def main():
123123

124124
if __name__ == "__main__":
125125
try:
126-
loop = asyncio.get_event_loop()
127-
loop.run_until_complete(main())
128-
loop.close()
126+
asyncio.run(main())
129127
except Exception as ex:
130128
logger.exception(ex)
131129
TestFail("Exception occurred when running tests.")

0 commit comments

Comments
 (0)