示例#1
0
 def assertFailuresRegexp(self, exc_class, pattern, callable_obj, *args, **kwargs):
     """Asserts the callable failed with the given exception and message."""
     try:
         with utils.wrap_all_failures():
             callable_obj(*args, **kwargs)
     except exceptions.WrappedFailure as e:
         self.assertThat(e, FailureRegexpMatcher(exc_class, pattern))
示例#2
0
 def assertFailuresRegexp(self, exc_class, pattern, callable_obj, *args,
                          **kwargs):
     """Asserts the callable failed with the given exception and message."""
     try:
         with utils.wrap_all_failures():
             callable_obj(*args, **kwargs)
     except exceptions.WrappedFailure as e:
         self.assertThat(e, FailureRegexpMatcher(exc_class, pattern))
def run(**store):
    # Creates a flow, each task in the flow will examine the kwargs passed in
    # here and based on those kwargs it will behave in a different manner
    # while executing; this allows for the calling code (see below) to show
    # different usages of the failure catching and handling mechanism.
    flow = uf.Flow("flow").add(FirstTask(), SecondTask())
    try:
        with utils.wrap_all_failures():
            taskflow.engines.run(flow, store=store, engine="parallel")
    except exceptions.WrappedFailure as ex:
        unknown_failures = []
        for failure in ex:
            if failure.check(FirstException):
                print("Got FirstException: %s" % failure.exception_str)
            elif failure.check(SecondException):
                print("Got SecondException: %s" % failure.exception_str)
            else:
                print("Unknown failure: %s" % failure)
                unknown_failures.append(failure)
        misc.Failure.reraise_if_any(unknown_failures)
示例#4
0
def run(**store):
    # Creates a flow, each task in the flow will examine the kwargs passed in
    # here and based on those kwargs it will behave in a different manner
    # while executing; this allows for the calling code (see below) to show
    # different usages of the failure catching and handling mechanism.
    flow = uf.Flow('flow').add(FirstTask(), SecondTask())
    try:
        with utils.wrap_all_failures():
            taskflow.engines.run(flow, store=store, engine='parallel')
    except exceptions.WrappedFailure as ex:
        unknown_failures = []
        for failure in ex:
            if failure.check(FirstException):
                print("Got FirstException: %s" % failure.exception_str)
            elif failure.check(SecondException):
                print("Got SecondException: %s" % failure.exception_str)
            else:
                print("Unknown failure: %s" % failure)
                unknown_failures.append(failure)
        misc.Failure.reraise_if_any(unknown_failures)