21
21
22
22
DEFAULT_BACKEND = {
23
23
'build-backend' : 'setuptools.build_meta:__legacy__' ,
24
- 'requires' : ['setuptools >= 40.8.0' ],
24
+ 'requires' : ['setuptools >= 40.8.0' , 'wheel' ],
25
25
}
26
26
27
27
@@ -43,6 +43,8 @@ def from_name(cls, name):
43
43
return CircularMockDistribution ()
44
44
elif name == 'nested_circular_dep' :
45
45
return NestedCircularMockDistribution ()
46
+ elif name == 'malformed_dep' :
47
+ return MalformedMockDistribution ()
46
48
raise _importlib .metadata .PackageNotFoundError
47
49
48
50
@@ -127,6 +129,11 @@ def read_text(self, filename):
127
129
"""
128
130
).strip ()
129
131
132
+ class MalformedMockDistribution (MockDistribution ):
133
+ def read_text (self , filename ):
134
+ if filename == 'METADATA' :
135
+ return ""
136
+
130
137
131
138
@pytest .mark .parametrize (
132
139
('requirement_string' , 'expected' ),
@@ -165,6 +172,12 @@ def test_check_dependency(monkeypatch, requirement_string, expected):
165
172
monkeypatch .setattr (_importlib .metadata , 'Distribution' , MockDistribution )
166
173
assert next (build .check_dependency (requirement_string ), None ) == expected
167
174
175
+ def test_check_dependency_bad_metadata (monkeypatch ):
176
+ monkeypatch .setattr (_importlib .metadata , 'Distribution' , MockDistribution )
177
+ with pytest .raises (TypeError ) as excinfo :
178
+ next (build .check_dependency ("malformed_dep==1.0.0" ), None )
179
+ assert "Package malformed_dep has malformed metadata and no version information could be found" in str (excinfo )
180
+
168
181
169
182
def test_bad_project (package_test_no_project ):
170
183
# Passing a nonexistent project directory
0 commit comments