Ejemplo n.º 1
0
 def testExecute(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 0)
     button.executeCallable()
     time.sleep(0.1)
     self.assertListEqual(self._result, ["a"])
     self.waitForPendingOperations(button)
 def testExecute(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 0)
     button.executeCallable()
     time.sleep(0.1)
     self.assertListEqual(self._result, ["a"])
     self.qapp.processEvents()
Ejemplo n.º 3
0
 def testExecute(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 0)
     button.executeCallable()
     time.sleep(0.1)
     self.assertListEqual(self._result, ["a"])
     self.qapp.processEvents()
 def testExecute(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 0)
     button.executeCallable()
     time.sleep(0.1)
     self.assertListEqual(self._result, ["a"])
     self.waitForPendingOperations(button)
Ejemplo n.º 5
0
 def testSaturateThreadPool(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 100)
     number = qt.silxGlobalThreadPool().maxThreadCount() * 2
     for _ in range(number):
         button.executeCallable()
     self.waitForPendingOperations(button)
     self.assertListEqual(self._result, ["a"] * number)
 def testSaturateThreadPool(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 100)
     number = qt.silxGlobalThreadPool().maxThreadCount() * 2
     for _ in range(number):
         button.executeCallable()
     self.waitForPendingOperations(button)
     self.assertListEqual(self._result, ["a"] * number)
 def testSaturateThreadPool(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 100)
     number = qt.QThreadPool.globalInstance().maxThreadCount() * 2
     for _ in range(number):
         button.executeCallable()
     time.sleep(number * 0.1 + 0.1)
     self.assertListEqual(self._result, ["a"] * number)
     self.qapp.processEvents()
Ejemplo n.º 8
0
 def testSaturateThreadPool(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._trace, "a", 100)
     number = qt.QThreadPool.globalInstance().maxThreadCount() * 2
     for _ in range(number):
         button.executeCallable()
     time.sleep(number * 0.1 + 0.1)
     self.assertListEqual(self._result, ["a"] * number)
     self.qapp.processEvents()
Ejemplo n.º 9
0
 def testSuccess(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._compute)
     button.beforeExecuting.connect(lambda: self._result.append("be"))
     button.started.connect(lambda: self._result.append("s"))
     button.succeeded.connect(lambda r: self._result.append(r))
     button.failed.connect(lambda e: self.fail("Unexpected exception"))
     button.finished.connect(lambda: self._result.append("f"))
     button.executeCallable()
     self.qapp.processEvents()
     time.sleep(0.1)
     self.qapp.processEvents()
     self.assertListEqual(self._result, ["be", "s", "result", "f"])
Ejemplo n.º 10
0
 def testFail(self):
     button = ThreadPoolPushButton()
     button.setCallable(self._computeFail)
     button.beforeExecuting.connect(lambda: self._result.append("be"))
     button.started.connect(lambda: self._result.append("s"))
     button.succeeded.connect(lambda r: self.fail("Unexpected success"))
     button.failed.connect(lambda e: self._result.append(str(e)))
     button.finished.connect(lambda: self._result.append("f"))
     with TestLogging('silx.gui.widgets.ThreadPoolPushButton', error=1):
         button.executeCallable()
         self.qapp.processEvents()
         time.sleep(0.1)
         self.qapp.processEvents()
     self.assertListEqual(self._result, ["be", "s", "exception", "f"])
Ejemplo n.º 11
0
 def testSuccess(self):
     listener = SignalListener()
     button = ThreadPoolPushButton()
     button.setCallable(self._compute)
     button.beforeExecuting.connect(listener.partial(test="be"))
     button.started.connect(listener.partial(test="s"))
     button.succeeded.connect(listener.partial(test="result"))
     button.failed.connect(listener.partial(test="Unexpected exception"))
     button.finished.connect(listener.partial(test="f"))
     button.executeCallable()
     self.qapp.processEvents()
     time.sleep(0.1)
     self.qapp.processEvents()
     result = listener.karguments(argumentName="test")
     self.assertListEqual(result, ["be", "s", "result", "f"])
Ejemplo n.º 12
0
 def testSuccess(self):
     listener = SignalListener()
     button = ThreadPoolPushButton()
     button.setCallable(self._compute)
     button.beforeExecuting.connect(listener.partial(test="be"))
     button.started.connect(listener.partial(test="s"))
     button.succeeded.connect(listener.partial(test="result"))
     button.failed.connect(listener.partial(test="Unexpected exception"))
     button.finished.connect(listener.partial(test="f"))
     button.executeCallable()
     self.qapp.processEvents()
     time.sleep(0.1)
     self.qapp.processEvents()
     result = listener.karguments(argumentName="test")
     self.assertListEqual(result, ["be", "s", "result", "f"])
Ejemplo n.º 13
0
 def testFail(self):
     listener = SignalListener()
     button = ThreadPoolPushButton()
     button.setCallable(self._computeFail)
     button.beforeExecuting.connect(listener.partial(test="be"))
     button.started.connect(listener.partial(test="s"))
     button.succeeded.connect(listener.partial(test="Unexpected success"))
     button.failed.connect(listener.partial(test="exception"))
     button.finished.connect(listener.partial(test="f"))
     with TestLogging('silx.gui.widgets.ThreadPoolPushButton', error=1):
         button.executeCallable()
         self.qapp.processEvents()
         time.sleep(0.1)
         self.qapp.processEvents()
     result = listener.karguments(argumentName="test")
     self.assertListEqual(result, ["be", "s", "exception", "f"])
     listener.clear()
Ejemplo n.º 14
0
 def testFail(self):
     listener = SignalListener()
     button = ThreadPoolPushButton()
     button.setCallable(self._computeFail)
     button.beforeExecuting.connect(listener.partial(test="be"))
     button.started.connect(listener.partial(test="s"))
     button.succeeded.connect(listener.partial(test="Unexpected success"))
     button.failed.connect(listener.partial(test="exception"))
     button.finished.connect(listener.partial(test="f"))
     with TestLogging('silx.gui.widgets.ThreadPoolPushButton', error=1):
         button.executeCallable()
         self.qapp.processEvents()
         time.sleep(0.1)
         self.qapp.processEvents()
     result = listener.karguments(argumentName="test")
     self.assertListEqual(result, ["be", "s", "exception", "f"])
     listener.clear()