示例#1
0
def test_WindowsCursor(static_config, image_dir) -> None:
    """Testing WindowsCursor members value."""
    win = WindowsCursor(static_config, image_dir, options=Options())
    assert win.config_file == static_config

    # We know 'out_dir' is not exists
    assert win.out_dir.exists() is True
示例#2
0
def test_WindowsCursor_generate_with_animated_config(animated_config,
                                                     image_dir) -> None:
    """Testing WindowsCursor generate method for generating animated (.ani) \
    cursor.
    """
    win = WindowsCursor(animated_config, image_dir, options=Options())
    win.generate()

    assert win.out.exists() is True
    assert win.out.suffix == ".ani"
    assert win.out.__sizeof__() > 0
示例#3
0
def test_WindowsCursor_generate_with_static_config(static_config,
                                                   image_dir) -> None:
    """Testing WindowsCursor generate method for generating static (.cur) \
    cursor.
    """
    win = WindowsCursor(static_config, image_dir, options=Options())
    win.generate()

    assert win.out.exists() is True
    assert win.out.suffix == ".cur"
    assert win.out.__sizeof__() > 0
示例#4
0
def test_WindowsCursor_exceptions(static_config, image_dir) -> None:
    """Testing WindowsCursor `framesets` Exceptions."""
    win = WindowsCursor(static_config, image_dir, options=Options())

    f1 = [
        (10, -1, -1, "test-0.png", 10),
        (9, -1, -1, "test-0.png", 10),
        (10, -1, -1, "test-1.png", 10),
        (9, -1, -1, "test-1.png", 10),
        (10, -1, -1, "test-2.png", 10),
        (9, -1, -1, "test-2.png", 10),
        (10, -1, -1, "test-3.png", 10),
        (9, -1, -1, "test-3.png", 10),
    ]

    with pytest.raises(ValueError) as excinfo:
        win.make_framesets(f1)

    assert (
        str(excinfo.value) ==
        "Frames are not sorted: frame 2 has size 10, but we have seen that already"
    )

    f2 = [
        (10, -1, -1, "test-0.png", 10),
        (10, -1, -1, "test-1.png", 10),
        (10, -1, -1, "test-2.png", 10),
        (10, -1, -1, "test-3.png", 10),
        (9, -1, -1, "test-0.png", 10),
        (9, -1, -1, "test-1.png", 10),
        (9, -1, -1, "test-2.png", 10),
    ]

    with pytest.raises(ValueError) as excinfo:
        win.make_framesets(f2)

    assert str(excinfo.value) == "Frameset 3 has size 1, expected 2"

    f3 = [
        (10, -1, -1, "test-0.png", 10),
        (10, -1, -1, "test-1.png", 10),
        (10, -1, -1, "test-2.png", 10),
        (10, -1, -1, "test-3.png", 10),
        (9, -1, -1, "test-0.png", 10),
        (9, -1, -1, "test-1.png", 10),
        (9, -1, -1, "test-2.png", 10),
        (9, -1, -1, "test-3.png", 1),
    ]

    with pytest.raises(ValueError) as excinfo:
        win.make_framesets(f3)

    assert (str(
        excinfo.value
    ) == "Frameset 1 has duration 1 for framesize 9, but 10 for framesize 10")

    f4 = [
        (10, -1, -1, "test-0.png", 10),
        (10, -1, -1, "test-1.png", 10),
        (10, -1, -1, "test-2.png", 10),
        (10, -1, -1, "test-3.png", 10),
        (9, -1, -1, "test-0.png", 10),
        (9, -1, -1, "test-1.png", 10),
        (9, -1, -1, "test-2.png", 10),
        (9, -1, -1, "test-3.png", 10),
    ]
    framesets = win.make_framesets(f4)
    ff = framesets[0][0]
    print(ff[0])