We have several unit tests floating about that test async functionality by manually handling an event loop. These tests should be run via async functions within IsolatedAsyncioTestCase classes rather than the standard TestCase that we're defaulting to.
There's a function I've got locally that's failure when called locally. The unit test looks like:
def test_can_be_fulfilled_0_a(self):
""" Test function against first job requirement for example 0 (requires all datasets, no preset fulfills). """
ex_num = 0
requirement_index = 0
job = self.example_jobs[ex_num]
result = self.loop.run_until_complete(
self.data_inquery_util.can_be_fulfilled(job.data_requirements[requirement_index]))
self.assertTrue(result[0])
If an IsolatedAsyncioTestCase were used, it could just be:
def test_can_be_fulfilled_0_a(self):
""" Test function against first job requirement for example 0 (requires all datasets, no preset fulfills). """
ex_num = 0
requirement_index = 0
job = self.example_jobs[ex_num]
result = await self.data_inquery_util.can_be_fulfilled(job.data_requirements[requirement_index])
self.assertTrue(result[0])
There are other places where tests fail due to event loops being closed. Letting the unit tests handle this behavior natively rather than relying on our own implementations would help prevent/fix issues involved with just running the tests in the first place.
We have several unit tests floating about that test async functionality by manually handling an event loop. These tests should be run via async functions within IsolatedAsyncioTestCase classes rather than the standard TestCase that we're defaulting to.
There's a function I've got locally that's failure when called locally. The unit test looks like:
If an IsolatedAsyncioTestCase were used, it could just be:
There are other places where tests fail due to event loops being closed. Letting the unit tests handle this behavior natively rather than relying on our own implementations would help prevent/fix issues involved with just running the tests in the first place.