예제 #1
0
def test_random_palette_rgb_mode_many_colours_called_that_many_times(
        mocked_method):
    colours.random_palette(100, mode="RGB")
    expected_call = 100
    assert (
        mocked_method.call_count == expected_call
    ), f"random_saturation was called {mocked_method.call_count} times, should have been {expected_call}"
예제 #2
0
def test_random_palette_default_generator_many_colours_called_that_many_times(
        mocked_method):
    colours.random_palette(100)
    expected_call = 100
    assert (
        mocked_method.call_count == expected_call
    ), f"random_saturation was called {mocked_method.call_count} times, should have been {expected_call}"
예제 #3
0
def test_random_palette_default_generator_with_one_colour_expected_result():
    assert len(colours.random_palette(1)) == 1
예제 #4
0
def test_random_palette_default_generator_with_one_colour_called_once(
        mocked_method):
    colours.random_palette(1)
    mocked_method.assert_called_once_with()
예제 #5
0
def test_random_palette_default_generator_zero_colours_expected_result():
    with pytest.raises(colours.ColourError):
        colours.random_palette(0)
예제 #6
0
def test_random_palette_rgb_mode_with_many_colours_expected_result():
    assert len(colours.random_palette(11, mode="RGB")) == 11
예제 #7
0
def test_random_palette_rgb_mode_with_one_colour_called_once(mocked_method):
    colours.random_palette(1, mode="RGB")
    mocked_method.assert_called_once_with()
예제 #8
0
def test_random_palette_l_mode_with_one_colour_expected_result():
    assert len(colours.random_palette(1, mode="L")) == 1
예제 #9
0
def test_random_palette_rgb_mode_zero_colours_expected_result():

    with pytest.raises(colours.ColourError):
        colours.random_palette(0)