@@ -43,6 +43,8 @@ def from_name(cls, name):
4343            return  CircularMockDistribution ()
4444        elif  name  ==  'nested_circular_dep' :
4545            return  NestedCircularMockDistribution ()
46+         elif  name  ==  'malformed_dep' :
47+             return  MalformedMockDistribution ()
4648        raise  _importlib .metadata .PackageNotFoundError 
4749
4850
@@ -127,6 +129,11 @@ def read_text(self, filename):
127129                """ 
128130            ).strip ()
129131
132+ class  MalformedMockDistribution (MockDistribution ):
133+     def  read_text (self , filename ):
134+         if  filename  ==  'METADATA' :
135+             return  "" 
136+ 
130137
131138@pytest .mark .parametrize ( 
132139    ('requirement_string' , 'expected' ), 
@@ -165,6 +172,13 @@ def test_check_dependency(monkeypatch, requirement_string, expected):
165172    monkeypatch .setattr (_importlib .metadata , 'Distribution' , MockDistribution )
166173    assert  next (build .check_dependency (requirement_string ), None ) ==  expected 
167174
175+ def  test_check_dependency_bad_metadata (monkeypatch ):
176+     monkeypatch .setattr (_importlib .metadata , 'Distribution' , MockDistribution )
177+     with  pytest .raises (TypeError ) as  excinfo :
178+         with  pytest .warns (DeprecationWarning ):
179+             next (build .check_dependency ("malformed_dep==1.0.0" ), None )
180+     assert  "Package malformed_dep has malformed metadata and no version information could be found"  in  str (excinfo )
181+ 
168182
169183def  test_bad_project (package_test_no_project ):
170184    # Passing a nonexistent project directory 
0 commit comments