def tearDown(self, **kwargs): """Clean up after a test.""" db = DBUtils(self.dbsession, self.settings) clear_all_tables = kwargs.get('clear_all_tables', False) dirs_to_clear = kwargs.get('dirs_to_clear', []) dirs_to_destroy = kwargs.get('dirs_to_destroy', []) if clear_all_tables: db.clear_all_tables(['language']) else: self.clear_all_models(self.dbsession) for dir_path in dirs_to_clear: h.clear_directory_of_files(getattr(self, dir_path)) for dir_name in dirs_to_destroy: h.destroy_all_directories(self.inflect_p.plural(dir_name), self.settings) if self.Session2: db = DBUtils(self.dbsession, self.settings2) clear_all_tables = kwargs.get('clear_all_tables', False) dirs_to_clear = kwargs.get('dirs_to_clear', []) dirs_to_destroy = kwargs.get('dirs_to_destroy', []) if clear_all_tables: db.clear_all_tables(['language']) else: self.clear_all_models(self.dbsession2) for attr_name in dirs_to_clear: dir_name = attr_name.replace('_path', '') dir_path = h.get_old_directory_path(dir_name, settings=self.settings2) h.clear_directory_of_files(dir_path) for dir_name in dirs_to_destroy: h.destroy_all_directories(self.inflect_p.plural(dir_name), self.settings2) self.tear_down_dbsession()
def test_zzz_cleanup(self): """Clean up after the tests.""" dbsession = self.dbsession db = DBUtils(dbsession, self.settings) # Destruction db.clear_all_tables() h.destroy_all_directories('users', self.settings) h.destroy_all_directories('corpora', self.settings) dbsession.commit() self.create_db()