def setUp(self): TmpPathTestCase.setUp(self) self.initialize_repo() self.context = context = mock.Mock() context.git = git.create() context.git.set_worktree(core.getcwd()) context.cfg = gitcfg.create(context) context.model = self.model = main.create(self.context) self.git = context.git self.cfg = context.cfg self.cfg.reset() gitcmds.reset()
def app_context(): """Create a repository in a temporary directory and return its ApplicationContext""" tmp_directory = tempfile.mkdtemp('-cola-test') current_directory = os.getcwd() os.chdir(tmp_directory) initialize_repo() context = Mock() context.git = git.create() context.git.set_worktree(core.getcwd()) context.cfg = gitcfg.create(context) context.model = main.create(context) context.cfg.reset() gitcmds.reset() yield context os.chdir(current_directory) shutil.rmtree(tmp_directory, onerror=remove_readonly)