Commits

Denis Bilenko committed f561b7e

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

it used to raise an error while it should return None

Comments (0)

Files changed (1)

greentest/greentest.py

         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'):
     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):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.