Example #1
0
def test_num_processes():

    # Can't have no processes
    with config.override(NUMBER_OF_CORES=0):
        with pytest.raises(ValueError):
            parallel.get_num_processes()

    # Negative numbers
    with config.override(NUMBER_OF_CORES=-1):
        assert parallel.get_num_processes() == 2

    # Too negative
    with config.override(NUMBER_OF_CORES=-3):
        with pytest.raises(ValueError):
            parallel.get_num_processes()

    # Requesting too many cores
    with config.override(NUMBER_OF_CORES=3):
        with pytest.raises(ValueError):
            parallel.get_num_processes()

    # Ok
    with config.override(NUMBER_OF_CORES=1):
        assert parallel.get_num_processes() == 1
Example #2
0
def test_num_processes():

    # Can't have no processes
    with config.override(NUMBER_OF_CORES=0):
        with pytest.raises(ValueError):
            parallel.get_num_processes()

    # Negative numbers
    with config.override(NUMBER_OF_CORES=-1):
        assert parallel.get_num_processes() == 2

    # Too negative
    with config.override(NUMBER_OF_CORES=-3):
        with pytest.raises(ValueError):
            parallel.get_num_processes()

    # Requesting more cores than available
    with config.override(NUMBER_OF_CORES=3):
        assert parallel.get_num_processes() == 2

    # Ok
    with config.override(NUMBER_OF_CORES=1):
        assert parallel.get_num_processes() == 1
Example #3
0
def test_num_processes_with_too_many_cores():
    with pytest.raises(ValueError):
        parallel.get_num_processes()
Example #4
0
def test_num_processes_with_negative_number_of_cores():
    assert parallel.get_num_processes() == 2
Example #5
0
def test_num_processes_number_of_cores_cant_be_0():
    with pytest.raises(ValueError):
        parallel.get_num_processes()