diff --git a/swh/storage/tests/storage_testing.py b/swh/storage/tests/storage_testing.py --- a/swh/storage/tests/storage_testing.py +++ b/swh/storage/tests/storage_testing.py @@ -57,21 +57,16 @@ self.objtmp.cleanup() super().tearDown() - def reset_tables(self): + def reset_storage_tables(self): + excluded = {'dbversion', 'entity', 'entity_history', 'listable_entity', + 'fossology_license', 'indexer_configuration'} + self.reset_db_tables(self.TEST_STORAGE_DB_NAME, excluded=excluded) + db = self.test_db[self.TEST_STORAGE_DB_NAME] conn = db.conn cursor = db.cursor - cursor.execute("""SELECT table_name FROM information_schema.tables - WHERE table_schema = %s""", ('public',)) - - tables = set(table for (table,) in cursor.fetchall()) - tables -= {'dbversion', 'entity', 'entity_history', 'listable_entity', - 'fossology_license', 'indexer_configuration'} - - for table in tables: - cursor.execute('truncate table %s cascade' % table) - cursor.execute('delete from entity where generated=true') cursor.execute('delete from entity_history where generated=true') + conn.commit() diff --git a/swh/storage/tests/test_storage.py b/swh/storage/tests/test_storage.py --- a/swh/storage/tests/test_storage.py +++ b/swh/storage/tests/test_storage.py @@ -545,7 +545,7 @@ } def tearDown(self): - self.reset_tables() + self.reset_storage_tables() super().tearDown() def fetch_tools(self):