Commit 23f75c9f authored by Denis Bilenko's avatar Denis Bilenko

greentest.py: fix switch_count property in case when CountingHub is not installed

it used to raise an error while it should return None
parent 0f16d394
......@@ -165,7 +165,7 @@ class TestCase(BaseTestCase):
return BaseTestCase.run(self, *args, **kwargs)
def setUp(self):
self.initial_switch_count = getattr(_get_hub(), 'switch_count', 0)
self.initial_switch_count = getattr(_get_hub(), 'switch_count', None)
def tearDown(self):
if hasattr(self, 'cleanup'):
......@@ -188,11 +188,12 @@ class TestCase(BaseTestCase):
def switch_count(self):
if self.switch_expected is None:
return
initial = getattr(self, 'initial_switch_count', None)
if initial is None:
if not hasattr(self, 'initial_switch_count'):
raise AssertionError('Cannot check switch_count (setUp() was not called)')
if self.initial_switch_count is None:
return
current = getattr(_get_hub(), 'switch_count', 0)
return current - initial
return current - self.initial_switch_count
@property
def testname(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment