Example #1
0
    def test_successful_args_and_kwargs_operation(self):
        def foo(scale, shift):
            return scale * 42 + shift

        scale, shift = 2, 4
        self.assertEqual(
            scale * 42 + shift,
            blocking_async_task(foo, args=(scale, ), kwargs={'shift': shift}))
Example #2
0
 def async_run_code(self, code_obj, result=None):
     """A monkey-patched replacement for the InteractiveShell.run_code method.
     It runs the in a separate thread and calls QApplication.processEvents
     periodically until the method finishes
     """
     # ipython 3.0 introduces a third argument named result
     if len(inspect.getargspec(orig_run_code).args) == 3:
         args = (code_obj, result)
     else:
         args = (code_obj,)
     return blocking_async_task(target=orig_run_code, args=args,
                                blocking_cb=QApplication.processEvents)
Example #3
0
 def async_run_code(self, code_obj, result=None):
     """A monkey-patched replacement for the InteractiveShell.run_code method.
     It runs the in a separate thread and calls QApplication.processEvents
     periodically until the method finishes
     """
     # ipython 3.0 introduces a third argument named result
     if len(inspect.getargspec(orig_run_code).args) == 3:
         args = (code_obj, result)
     else:
         args = (code_obj, )
     return blocking_async_task(target=orig_run_code,
                                args=args,
                                blocking_cb=QApplication.processEvents)
Example #4
0
    def test_successful_positional_args_operation(self):
        def foo(shift):
            return 42 + shift

        shift = 2
        self.assertEqual(42 + shift, blocking_async_task(foo, args=(shift, )))
Example #5
0
    def test_successful_no_arg_operation_without_callback(self):
        def foo():
            return 42

        self.assertEqual(42, blocking_async_task(foo))
Example #6
0
    def test_successful_args_and_kwargs_operation(self):
        def foo(scale, shift):
            return scale*42 + shift

        scale, shift = 2, 4
        self.assertEqual(scale*42 + shift, blocking_async_task(foo, args=(scale,), kwargs={'shift': shift}))
Example #7
0
    def test_successful_positional_args_operation(self):
        def foo(shift):
            return 42 + shift

        shift = 2
        self.assertEqual(42 + shift, blocking_async_task(foo, args=(shift,)))
Example #8
0
    def test_successful_no_arg_operation_without_callback(self):
        def foo():
            return 42

        self.assertEqual(42, blocking_async_task(foo))