def deepstar_path(): with tempdir() as tempdir_: with mock.patch.dict(os.environ, {'DEEPSTAR_PATH': tempdir_}): Deepstar.init() try: yield finally: Model.close()
def test_isolation_level(self): with deepstar_path(): Model.db.execute('CREATE TABLE test (test TEXT)') Model.db.execute("INSERT INTO test (test) VALUES ('test')") Model.close() Model.init() self.assertEqual( Model.db.execute('SELECT test FROM test').fetchone(), ('test', )) # noqa
def test_check_same_thread(self): with deepstar_path(): def a(): Model.init() thread = threading.Thread(target=a) Model.close() thread.start() thread.join() Model.close()
def test_close(self): with deepstar_path(): Model.close() self.assertEqual(Model.db, None)