def exec_(self, options=None, args=None): container = inject.get_injector() if container is None: return None print(options) # if options.console: return None # window = container.get_instance('window') # if window is None: return None # config = container.get_instance('config') # if config is None: return None # window.show() # width = int(config.get('window.width')) # height = int(config.get('window.height')) # animation = QtCore.QPropertyAnimation(window, b'size') # animation.setEndValue(QtCore.QSize(width, height)) # animation.setStartValue(QtCore.QSize(800, 600)) # animation.setDuration(200) # animation.start() return super(Application, self).exec_()
def testRegisterUnregister(self): injector = Injector() injector2 = Injector() injector.register() self.assertTrue(inject.get_injector() is injector) injector2.unregister() self.assertTrue(inject.get_injector() is injector) injector.unregister() self.assertTrue(inject.get_injector() is None) injector.register() inject.unregister() self.assertTrue(inject.get_injector() is None)
def test_configure__should_create_injector(self): injector0 = inject.configure() injector1 = inject.get_injector() assert injector0 assert injector0 is injector1
def test_configure_once__should_create_injector(self): injector = inject.configure_once() assert inject.get_injector() is injector
def overwrite_binding(key, constructor): injector = inject.get_injector() injector._bindings[key] = constructor