diff --git a/gramps/plugins/tool/testcasegenerator.py b/gramps/plugins/tool/testcasegenerator.py index 72bd3da39..e2363f22b 100644 --- a/gramps/plugins/tool/testcasegenerator.py +++ b/gramps/plugins/tool/testcasegenerator.py @@ -71,7 +71,6 @@ from gramps.gen.db import DbTxn from gramps.gen.mime import get_type from gramps.gui.plug import tool from gramps.gen.utils.string import conf_strings -from gramps.gui.utils import ProgressMeter from gramps.gen.utils.lds import TEMPLES from gramps.gen.db.dbconst import * from gramps.gen.const import ICON, LOGO, SPLASH @@ -180,6 +179,7 @@ class TestcaseGenerator(tool.BatchTool): parent_window = uistate.window else: parent_window = None + self.progress = user.progress self.person = None if dbstate.db.readonly: return @@ -338,81 +338,81 @@ class TestcaseGenerator(tool.BatchTool): else: self.window = None - self.progress = ProgressMeter( - _('Generating testcases'), '', parent=self.window) self.transaction_count = 0; if self.options.handler.options_dict['lowlevel']: - self.progress.set_pass(_('Generating low level database errors'), - 1) - self.test_low_level(); self.progress.step() + with self.progress(_('Generating testcases'), + _('Generating low level database errors'), + 1) as step: + self.test_low_level() + step() if self.options.handler.options_dict['bugs'] or \ self.options.handler.options_dict['persons']: self.generate_tags() if self.options.handler.options_dict['bugs']: - self.generate_data_errors() + with self.progress(_('Generating testcases'), + _('Generating database errors'), + 18) as step: + self.generate_data_errors(step) if self.options.handler.options_dict['persons']: - self.progress.set_pass(_('Generating families'), - self.options.handler.options_dict['person_count']) - self.person_count = 0 - self.progress_step = self.progress.step + with self.progress(_('Generating testcases'), + _('Generating families'), + self.options.handler.options_dict['person_count']) \ + as self.progress_step: + self.person_count = 0 - while True: - if not self.persons_todo: - ph = self.generate_person(0) - self.persons_todo.append( ph) - self.parents_todo.append( ph) - person_h = self.persons_todo.pop(0) - self.generate_family(person_h) - if randint(0,3) == 0: + while True: + if not self.persons_todo: + ph = self.generate_person(0) + self.persons_todo.append( ph) + self.parents_todo.append( ph) + person_h = self.persons_todo.pop(0) self.generate_family(person_h) - if randint(0,7) == 0: - self.generate_family(person_h) - if self.person_count > self.options.handler.options_dict['person_count']: - break - for child_h in self.parents_todo: - self.generate_parents(child_h) + if randint(0,3) == 0: + self.generate_family(person_h) + if randint(0,7) == 0: + self.generate_family(person_h) if self.person_count > self.options.handler.options_dict['person_count']: break - self.progress.close() + for child_h in self.parents_todo: + self.generate_parents(child_h) + if self.person_count > self.options.handler.options_dict['person_count']: + break if( not cli): self.top.destroy() - def generate_data_errors(self): + def generate_data_errors(self, step): """This generates errors in the database to test src/plugins/tool/Check The module names correspond to the checking methods in src/plugins/tool/Check.CheckIntegrity """ - self.progress.set_pass(_('Generating database errors'), - 18) # The progress meter is normally stepped every time a person is # generated by generate_person. However in this case, generate_person is # called by some of the constituent functions, but we only want the # meter to be stepped every time a test function has been completed. self.progress_step = lambda: None - self.test_fix_encoding(); self.progress.step() - self.test_fix_ctrlchars_in_notes(); self.progress.step() - self.test_cleanup_missing_photos(); self.progress.step() - self.test_cleanup_deleted_name_formats(); self.progress.step() - self.test_cleanup_empty_objects(); self.progress.step() - self.test_check_for_broken_family_links(); self.progress.step() - self.test_check_parent_relationships(); self.progress.step() - self.test_cleanup_empty_families(); self.progress.step() - self.test_cleanup_duplicate_spouses(); self.progress.step() - self.test_check_events(); self.progress.step() - self.test_check_person_references(); self.progress.step() - self.test_check_family_references(); self.progress.step() - self.test_check_place_references(); self.progress.step() - self.test_check_source_references(); self.progress.step() - self.test_check_citation_references(); self.progress.step() - self.test_check_media_references(); self.progress.step() - self.test_check_repo_references(); self.progress.step() - self.test_check_note_references(); self.progress.step() - self.progress.close() + self.test_fix_encoding(); step() + self.test_fix_ctrlchars_in_notes(); step() + self.test_cleanup_missing_photos(); step() + self.test_cleanup_deleted_name_formats(); step() + self.test_cleanup_empty_objects(); step() + self.test_check_for_broken_family_links(); step() + self.test_check_parent_relationships(); step() + self.test_cleanup_empty_families(); step() + self.test_cleanup_duplicate_spouses(); step() + self.test_check_events(); step() + self.test_check_person_references(); step() + self.test_check_family_references(); step() + self.test_check_place_references(); step() + self.test_check_source_references(); step() + self.test_check_citation_references(); step() + self.test_check_media_references(); step() + self.test_check_repo_references(); step() + self.test_check_note_references(); step() def test_low_level(self): with DbTxn(_("Testcase generator step %d") % self.transaction_count,