New submission from Petter Strandmark <petter.strandm...@gmail.com>:

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.

----------
components: Library (Lib)
messages: 313211
nosy: Petter Strandmark
priority: normal
severity: normal
status: open
title: unittest: Automatically run coroutines in a loop
type: enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32992>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to