This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Petter S
Recipients Petter S
Date 2018-03-04.12:39:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1520167156.98.0.467229070634.issue32992@psf.upfronthosting.co.za>
In-reply-to
Content
I am wondering whether it would be useful for unittest.TestCase to automatically run test methods that are coroutines within the default asyncio loop.

Example:

	class TestAsync(unittest.TestCase):

		async def test_foo(self):
			result = await foo()
			self.assertEqual(result, 42)

the test runner would then run test_foo within the default loop. If needed, we could also add functionality for providing a loop other than the default to the test class.

It seems to me that this functionality would be pretty easy to add to Lib/unittest/case.py:615 .

Personally, I think it would be useful. Right now I have to append every test case with a personal @run_in_loop decorator and I think unittest.TestCase could do this for me without breaking anything.
History
Date User Action Args
2018-03-04 12:39:17Petter Ssetrecipients: + Petter S
2018-03-04 12:39:16Petter Ssetmessageid: <1520167156.98.0.467229070634.issue32992@psf.upfronthosting.co.za>
2018-03-04 12:39:16Petter Slinkissue32992 messages
2018-03-04 12:39:16Petter Screate