Questions on working with unittest.IsolatedAsyncioTestCase

Mond Wan mondwan at anywherenetworks.com
Thu Nov 7 22:19:19 EST 2019


Hello all,

I would like to ask for helps on working with **unittest.IsolatedAsyncioTestCase**.

Q1: How to handle asyncio.CancelledError inside IsolatedAsyncioTestCase.

My test is hanging up if there are futures being cancelled some how. Is there a way for me to configure IsolatedAsyncioTestCase to throw any exceptions
to crash the main program such that I can read the line number?

I have also issue a post on stackoverflow, which include the codes I have written for explaining the question.

Stackoverflow: https://stackoverflow.com/questions/58744043/how-to-handle-cancellederror-with-python-3-8-unittest-isolatedasynciotestcase


Q2: addAsyncCleanup vs asyncTearDown?

In the py3.8 manual, there is a method **addAsyncCleanup** for cleaning up stuff in async way. Why we need this instead of merging them altogether
into **asyncTearDown** at all?


Q3: Is it possible to configure a timeout mechanism for IsolatedAsyncioTestCase?

During my development, my tests always pending in somewhere. I cannot located them until I add print statements line by line. Is it possible to
configure the IsolatedAsyncioTestCase to crash the test, with line number, after specific period if such future is not resolved?


Thanks for your time

--

Mond WAN

Senior Engineer, Engineering Department

Anywhere Networks
Mobile/WhatsApp: +852 3899 1928

mondwan@anywherenetworks.com

www.AnywhereNetworks.com

P2 Wireless Technologies is now Anywhere Networks!

[Anywhere Networks]<https://anywherenetworks.com>

Disclaimer: This email and its attachment(s) are solely for the use of the intended addressee and may contain confidential information. If you are not the intended recipient, you must not use, distribute or copy this email. If you have received this email in error, please notify the sender immediately and delete this email. No employee or agent is authorized to bind the company or conclude a binding agreement on behalf of the company without express written approval by an authorized senior officer of the company. In no event will this email or its content be construed as written approval.




More information about the Python-list mailing list