from unittest import TestCase
import asyncio
import inject


class BaseTestInject(TestCase):
    def tearDown(self):
        inject.clear()
    
    def run_async(self, awaitable):
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        try:
            ret = loop.run_until_complete(awaitable)
        finally:
            loop.close()
        return ret
