Hi, I'm seeing some behavior from some code I'm trying to add to the test suite that I just don't understand at all.

When I run the following code inside the test suite, I get a runtime error with the text "Got right exception".

                       raised = False
                       try:
                               self._do_uninstall(api_obj, ["example_pkg"])
                       except api_errors.WrapSuccessfulIndexingException:
                               raised = True
                               raise RuntimeError("Got right exception")
                       except Exception, e:
raise RuntimeError("Got some exception,%s" % e.__class__.__name__)



When I change the code to instead be this:
                       raised = False
                       try:
                               self._do_uninstall(api_obj, ["example_pkg"])
                       except api_errors.WrapSuccessfulIndexingException:
                               raised = True
                               raise RuntimeError("Got right exception")
                       except Exception, e:
raise RuntimeError("Got some exception,%s" % e.__class__.__name__)
                       if not raised:
                               raise RuntimeError("Got no exception")

I see different behavior. Now, I see the "Got no exception" runtime error. Now, as far as I can tell, that means that adding the if statement after the try/except block is somehow modifying the behavior of the code within the try/except block. Frankly, that just strikes me as weird and makes me question my sanity.

As a final point of comparison, when I do:
self.assertRaises(api_errors.WrapSuccessfulIndexingException, self._do_uninstall, api_obj, ["example_pkg"])
I get:
AssertionError: WrapSuccessfulIndexingException not raised


If anyone has seen behavior like this, or wants to point out the painfully obvious mistake I'm making, please let me know, cause I'm clueless.

Thanks,
Brock
_______________________________________________
pkg-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/pkg-discuss

Reply via email to