示例#1
0
def test_remove_resource():
    qrc = QRCTestFile("res.qrc").add_qresource().add_file("test.txt").build()
    assert qrc.remove_resource("test.txt", "/").text == "test.txt"

    with pytest.raises(QresourceError) as e:
        qrc.get_file("test.txt", "/")
    assert str(e.value) == ("Error: No <file> child corresponding to "
                            "'test.txt' in qresource \'/\'")
示例#2
0
def test_fill_qresource_with_root_prefix(config, test_resources):
    # Test with prefix "/"
    qrc = QRCTestFile("res.qrc").add_qresource().add_qresource("/images")
    fill_qresource(qrc, "resources", "/")

    assert qrc.list_resources("/") == ["resources/file.txt"]
    assert qrc.list_resources("/images") == []

    # Check if resources are relative paths from project directory
    for resource in qrc.list_resources("/"):
        assert resource.startswith("resources/")
示例#3
0
def test_fill_qresource_with_any_prefix(config, test_resources):
    # Test with prefix "/images"
    qrc = QRCTestFile("res.qrc").add_qresource().add_qresource("/images")
    fill_qresource(qrc, "resources/images", "/images")

    assert qrc.list_resources("/") == []
    assert sorted(qrc.list_resources("/images")) != sorted([
           "resources/musics/outro.ogg",
           "resources/musics/intro.ogg",
           "resources/musics/solos/solo2.mp3",
           "resources/musics/solos/solo1.mp3",
           "resources/musics/solos/best/best_solo2.mp3",
           "resources/musics/solos/best/best_solo1.mp3"
    ])

    # Check if resources are relative paths from project directory
    for resource in qrc.list_resources("/images"):
        assert resource.startswith("resources/images")
示例#4
0
def test_add_file():
    qrc = QRCTestFile("res.qrc").add_qresource().add_file("test.txt").build()

    assert qrc.get_file("test.txt", "/").text == "test.txt"
示例#5
0
def test_add_qresource():
    qrc = QRCTestFile("res.qrc").add_qresource("/").build()

    qrc.get_qresource("/")