devtools/testlib.py
changeset 8695 358d8bed9626
parent 8694 d901c36bcfce
child 8696 0bb18407c053
equal deleted inserted replaced
8694:d901c36bcfce 8695:358d8bed9626
   313         if previous_failure is not None:
   313         if previous_failure is not None:
   314             self.skipTest('repository is not initialised: %r' % previous_failure)
   314             self.skipTest('repository is not initialised: %r' % previous_failure)
   315         try:
   315         try:
   316             self._init_repo()
   316             self._init_repo()
   317             self.addCleanup(self._close_cnx)
   317             self.addCleanup(self._close_cnx)
   318         except Exception, ex:
   318         except Exception as ex:
   319             self.__class__._repo_init_failed = ex
   319             self.__class__._repo_init_failed = ex
   320             raise
   320             raise
   321         resume_tracing()
   321         resume_tracing()
   322         self.setup_database()
   322         self.setup_database()
   323         self.commit()
   323         self.commit()
   718         """call the given callback with req as argument, expecting to get a
   718         """call the given callback with req as argument, expecting to get a
   719         Redirect exception
   719         Redirect exception
   720         """
   720         """
   721         try:
   721         try:
   722             callback(req)
   722             callback(req)
   723         except Redirect, ex:
   723         except Redirect as ex:
   724             return self._parse_location(req, ex.location)
   724             return self._parse_location(req, ex.location)
   725         else:
   725         else:
   726             self.fail('expected a Redirect exception')
   726             self.fail('expected a Redirect exception')
   727 
   727 
   728     def expect_redirect_handle_request(self, req, path='edit'):
   728     def expect_redirect_handle_request(self, req, path='edit'):
  1085         q = make_relations_queries(self.schema, edict, cu, ignored_relations,
  1085         q = make_relations_queries(self.schema, edict, cu, ignored_relations,
  1086                                    existingrels=existingrels)
  1086                                    existingrels=existingrels)
  1087         for rql, args in q:
  1087         for rql, args in q:
  1088             try:
  1088             try:
  1089                 cu.execute(rql, args)
  1089                 cu.execute(rql, args)
  1090             except ValidationError, ex:
  1090             except ValidationError as ex:
  1091                 # failed to satisfy some constraint
  1091                 # failed to satisfy some constraint
  1092                 print 'error in automatic db population', ex
  1092                 print 'error in automatic db population', ex
  1093                 self.session.commit_state = None # reset uncommitable flag
  1093                 self.session.commit_state = None # reset uncommitable flag
  1094         self.post_populate(cu)
  1094         self.post_populate(cu)
  1095         self.commit()
  1095         self.commit()