def test_run_async_raised(self):
     self.assertEqual(connections._get_storage(), {})
     self.assertEqual(self.somevalue, 1)
     with self.assertRaises(Exception):
         run_async(self.init_raise())
     self.assertEqual(connections._get_storage(), {})
     self.assertEqual(self.somevalue, 3)
Beispiel #2
0
 async def init_orm() -> None:  # pylint: disable=W0612
     await Tortoise.init(config=config,
                         config_file=config_file,
                         db_url=db_url,
                         modules=modules)
     logger.info("Tortoise-ORM started, %s, %s", connections._get_storage(),
                 Tortoise.apps)
     if generate_schemas:
         logger.info("Tortoise-ORM generating schema")
         await Tortoise.generate_schemas()
 def test_run_async(self):
     self.assertEqual(connections._get_storage(), {})
     self.assertEqual(self.somevalue, 1)
     run_async(self.init())
     self.assertEqual(connections._get_storage(), {})
     self.assertEqual(self.somevalue, 2)
 async def init_raise(self):
     await Tortoise.init(db_url="sqlite://:memory:", modules={"models": []})
     self.somevalue = 3
     self.assertNotEqual(connections._get_storage(), {})
     raise Exception("Some exception")