Example #1
0
    def test_initial_running_strategy_with_coroutine(
            self, executor_as_green_thread: SimpleExecutor):
        executor_as_green_thread._initial_running_strategy()

        from multirunnable.executor import General_Runnable_Strategy
        assert General_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        assert isinstance(
            General_Runnable_Strategy, GreenThreadStrategy
        ), "It should be an sub-instance of 'GreenThreadStrategy'."
Example #2
0
    def test_initial_running_strategy_with_asynchronous(
            self, executor_as_asynchronous: SimpleExecutor):
        executor_as_asynchronous._initial_running_strategy()

        from multirunnable.executor import General_Runnable_Strategy
        assert General_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        assert isinstance(
            General_Runnable_Strategy, AsynchronousStrategy
        ), "It should be an sub-instance of 'AsynchronousStrategy'."
Example #3
0
    def test_initial_running_strategy_with_parallel(
            self, executor_as_process: SimpleExecutor):
        executor_as_process._initial_running_strategy()

        from multirunnable.executor import General_Runnable_Strategy
        assert General_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        assert isinstance(
            General_Runnable_Strategy, ProcessStrategy
        ), "It should be an sub-instance of 'ProcessStrategy'."
Example #4
0
    def test_initial_running_strategy(self, instantiate_executor: SimpleExecutor):
        instantiate_executor._initial_running_strategy()

        from multirunnable.executor import General_Runnable_Strategy
        assert General_Runnable_Strategy is not None, "It should be assign running-strategy instance."
        _rmode = get_current_mode(force=True)
        if _rmode is RunningMode.Parallel:
            assert isinstance(General_Runnable_Strategy, ProcessStrategy), "It should be an sub-instance of 'ProcessStrategy'."
        elif _rmode is RunningMode.Concurrent:
            assert isinstance(General_Runnable_Strategy, ThreadStrategy), "It should be an sub-instance of 'ThreadStrategy'."
        elif _rmode is RunningMode.Parallel.GreenThread:
            assert isinstance(General_Runnable_Strategy, GreenThreadStrategy), "It should be an sub-instance of 'GreenThreadStrategy'."
        elif _rmode is RunningMode.Asynchronous:
            assert isinstance(General_Runnable_Strategy, AsynchronousStrategy), "It should be an sub-instance of 'AsynchronousStrategy'."
        else:
            raise ValueError("The RunningMode has the unexpected mode.")