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): ...@@ -165,7 +165,7 @@ class TestCase(BaseTestCase):
return BaseTestCase.run(self, *args, **kwargs) return BaseTestCase.run(self, *args, **kwargs)
def setUp(self): 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): def tearDown(self):
if hasattr(self, 'cleanup'): if hasattr(self, 'cleanup'):
...@@ -188,11 +188,12 @@ class TestCase(BaseTestCase): ...@@ -188,11 +188,12 @@ class TestCase(BaseTestCase):
def switch_count(self): def switch_count(self):
if self.switch_expected is None: if self.switch_expected is None:
return return
initial = getattr(self, 'initial_switch_count', None) if not hasattr(self, 'initial_switch_count'):
if initial is None:
raise AssertionError('Cannot check switch_count (setUp() was not called)') 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) current = getattr(_get_hub(), 'switch_count', 0)
return current - initial return current - self.initial_switch_count
@property @property
def testname(self): 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