def test__open_database_during_init(self): temp_dir = self.createTempDir(prefix='u1db-test-') path = temp_dir + '/initialised.db' db = SQLCipherDatabase.__new__( SQLCipherDatabase) db._db_handle = dbapi2.connect(path) # db is there but not yet init-ed db._syncers = {} c = db._db_handle.cursor() c.execute('PRAGMA key="%s"' % PASSWORD) self.addCleanup(db.close) observed = [] class SQLiteDatabaseTesting(SQLCipherDatabase): WAIT_FOR_PARALLEL_INIT_HALF_INTERVAL = 0.1 @classmethod def _which_index_storage(cls, c): res = SQLCipherDatabase._which_index_storage(c) db._ensure_schema() # init db observed.append(res[0]) return res db2 = SQLiteDatabaseTesting._open_database(path, PASSWORD) self.addCleanup(db2.close) self.assertIsInstance(db2, SQLCipherDatabase) self.assertEqual( [None, SQLCipherDatabase._index_storage_value], observed)