Esempio n. 1
0
def test_read_non_existent_wheel_file_name():
    """Test reading a wheel file which doesn't exist"""

    file_name = "/foo/bar/baz.whl"
    with pytest.raises(exceptions.InvalidDistribution,
                       match=f"No such file: {file_name}"):
        wheel.Wheel(file_name)
Esempio n. 2
0
def test_read_invalid_wheel_extension():
    """Test reading a wheel file without a .whl extension"""

    file_name = os.path.join(os.path.dirname(__file__), "fixtures/twine-1.5.0.tar.gz")
    with pytest.raises(
        exceptions.InvalidDistribution, match=f"Not a known archive format: {file_name}"
    ):
        wheel.Wheel(file_name)
Esempio n. 3
0
def test_read_wheel_empty_metadata(tmpdir):
    """Test reading a wheel file with an empty METADATA file"""

    whl_file = tmpdir.mkdir("wheel").join("not-a-wheel.whl")
    with zipfile.ZipFile(whl_file, "w") as zip_file:
        zip_file.writestr("METADATA", "")

    with pytest.raises(exceptions.InvalidDistribution,
                       match=f"No METADATA in archive: {whl_file}"):
        wheel.Wheel(whl_file)
Esempio n. 4
0
def test_read_invalid_wheel_extension():
    """Raise an exception when file is missing .whl extension."""
    file_name = str(
        pathlib.Path(__file__).parent / "fixtures" / "twine-1.5.0.tar.gz")
    with pytest.raises(
            exceptions.InvalidDistribution,
            match=re.escape(
                f"Not a known archive format for file: {file_name}"),
    ):
        wheel.Wheel(file_name)
Esempio n. 5
0
def test_read_wheel_empty_metadata(tmpdir):
    """Raise an exception when a wheel file is missing METADATA."""
    whl_file = tmpdir.mkdir("wheel").join("not-a-wheel.whl")
    with zipfile.ZipFile(whl_file, "w") as zip_file:
        zip_file.writestr("METADATA", "")

    with pytest.raises(
            exceptions.InvalidDistribution,
            match=re.escape(f"No METADATA in archive: {whl_file}"),
    ):
        wheel.Wheel(whl_file)
Esempio n. 6
0
def example_wheel(request):
    return wheel.Wheel(request.param)
Esempio n. 7
0
def example_wheel(request):
    file_name = os.path.join(helpers.TESTS_DIR, request.param)
    return wheel.Wheel(file_name)
Esempio n. 8
0
def test_read_non_existent_wheel_file_name():
    """Raise an exception when wheel file doesn't exist."""
    file_name = str(pathlib.Path("/foo/bar/baz.whl").resolve())
    with pytest.raises(exceptions.InvalidDistribution,
                       match=re.escape(f"No such file: {file_name}")):
        wheel.Wheel(file_name)