def test_cleanup_WhenCalled_GPIOCleanupIsCalled(self): mockGPIO = Mock() lp = LightProvider(mockGPIO) lp.cleanup() self.assertTrue(mockGPIO.cleanup.called)
self.lights.clearPins() self.lights.cleanup() if self.isDisplayTime: try: status = self.getStatusToDisplay() self.lights.clearPins() self.lights.lightPin(self.getPinToLightUp(status)) except KeyboardInterrupt: self.lights.cleanup() except: print 'Unhandled error occurred: ', sys.exc_info()[0] if __name__ == '__main__': try: appConfig = AppConfig() lights = LightProvider(GPIO) tc = TeamCityProvider(requests, appConfig, 'jgarrison', 'password') tv = TimeValidator(datetime, WEHolidays()) buildLights = TCBuildLights(lights, tc, tv) lights.setupGPIO() while 1: buildLights.main() time.sleep(5) except KeyboardInterrupt: lights.cleanup()