Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #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)
Пример #6
0
def example_wheel(request):
    return wheel.Wheel(request.param)
Пример #7
0
def example_wheel(request):
    file_name = os.path.join(helpers.TESTS_DIR, request.param)
    return wheel.Wheel(file_name)
Пример #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)