Skip to content

Commit

Permalink
Use regex for exception
Browse files Browse the repository at this point in the history
  • Loading branch information
bhrutledge committed May 18, 2021
1 parent 5fc0e5a commit e5abeac
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tests/test_package.py
Expand Up @@ -274,11 +274,13 @@ def EmptyDist(filename):
monkeypatch.setattr(package_file, "DIST_TYPES", {"bdist_wheel": EmptyDist})
filename = "tests/fixtures/twine-1.5.0-py2.py3-none-any.whl"

with pytest.raises(exceptions.InvalidDistribution) as err:
package_file.PackageFile.from_filename(filename, comment=None)
error_message = (
r"Invalid distribution metadata.*"
"1.0, 1.1, 1.2, 2.0 and 2.1"
)

assert "Invalid distribution metadata" in err.value.args[0]
assert "1.0, 1.1, 1.2, 2.0, and 2.1" in err.value.args[0]
with pytest.raises(exceptions.InvalidDistribution, match=error_message):
package_file.PackageFile.from_filename(filename, comment=None)


def test_malformed_from_file(monkeypatch):
Expand Down

0 comments on commit e5abeac

Please sign in to comment.