From ac94d901a2a1b9fc8683b44adeec2d3d6f9fa5bb Mon Sep 17 00:00:00 2001 From: Michal Minar Date: Wed, 8 Jan 2014 16:14:48 +0100 Subject: tests: ensure the use of exceptions is well defined Some tests expect that exceptions won't be thrown out of LMIShell's functions. Others prefers them and enable them globally. This causes problems when running under nosetests all provider tests at once. Tests that modified enablement of exception throws globally caused others to fail. This patch makes sure that each TestCase has defined use of exceptions. Default state is to have them disabled. If a TestCase prefers having them enabled, just one variable needs to be overriden in its body: class AccountBase(lmibase.LmiTestCase): USE_EXCEPTIONS = True --- src/python/lmi/test/lmibase.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/python') diff --git a/src/python/lmi/test/lmibase.py b/src/python/lmi/test/lmibase.py index 242c002..d01c647 100644 --- a/src/python/lmi/test/lmibase.py +++ b/src/python/lmi/test/lmibase.py @@ -74,6 +74,12 @@ class LmiTestCase(base.BaseLmiTestCase): #: it wants to test indication events. NEEDS_INDICATIONS = False + #: Says, whether the LMIShell intestines shall throw exception upon + #: failure or error. Having them disabled is a default behaviour of + #: LMIShell. If the TestCase prefers to have them enabled, it shall + #: override this property in its body and set it to ``True``. + USE_EXCEPTIONS = False + _SYSTEM_INAME = None @classmethod @@ -88,6 +94,7 @@ class LmiTestCase(base.BaseLmiTestCase): @classmethod def setUpClass(cls): base.BaseLmiTestCase.setUpClass.im_func(cls) + LMIUtil.lmi_set_use_exceptions(cls.USE_EXCEPTIONS) if cls.needs_indications(): cls.indication_port = random.randint(12000, 13000) cls.indication_queue = Queue.Queue() -- cgit