Simplify wheel_version tests
@@ -3,6 +3,7 @@ import csv
import logging
import os
import textwrap
+from email import message_from_string
import pytest
from mock import Mock, patch
@@ -236,15 +237,9 @@ def test_wheel_metadata_fails_on_bad_encoding(tmpdir):
assert "error decoding WHEEL" in str(e.value)
-def test_wheel_version_fails_on_no_wheel_version(tmpdir):
- dist_info_dir = tmpdir / "simple-0.1.0.dist-info"
- dist_info_dir.mkdir()
- dist_info_dir.joinpath("METADATA").touch()
- dist_info_dir.joinpath("WHEEL").touch()
-
- metadata = wheel.wheel_metadata(str(tmpdir))
+def test_wheel_version_fails_on_no_wheel_version():
with pytest.raises(UnsupportedWheel) as e:
- wheel.wheel_version(metadata)
+ wheel.wheel_version(message_from_string(""))
assert "missing Wheel-Version" in str(e.value)
@@ -253,17 +248,11 @@ def test_wheel_version_fails_on_no_wheel_version(tmpdir):
("1.b",),
("1.",),
])
-def test_wheel_version_fails_on_bad_wheel_version(tmpdir, version):
- dist_info_dir = tmpdir / "simple-0.1.0.dist-info"
- dist_info_dir.mkdir()
- dist_info_dir.joinpath("METADATA").touch()
- dist_info_dir.joinpath("WHEEL").write_text(
- "Wheel-Version: {}".format(version)
- )
-
- metadata = wheel.wheel_metadata(str(tmpdir))
+def test_wheel_version_fails_on_bad_wheel_version(version):
with pytest.raises(UnsupportedWheel) as e:
- wheel.wheel_version(metadata)
+ wheel.wheel_version(
+ message_from_string("Wheel-Version: {}".format(version))
+ )
assert "invalid Wheel-Version" in str(e.value)
