@@ -373,8 +373,8 @@ def test_validate_files(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> Non
373373    [ 
374374        (pypi_wheel_url , pypi_wheel_filename ), 
375375        (pypi_sdist_url , pypi_sdist_filename ), 
376-         (pypi_wheel_abbrev , pypi_wheel_filename ), 
377-         (pypi_sdist_abbrev , pypi_sdist_filename ), 
376+         (f"pypi: { pypi_wheel_filename } " pypi_wheel_filename ), 
377+         (f"pypi: { pypi_sdist_filename } " pypi_sdist_filename ), 
378378    ], 
379379) 
380380def  test_verify_pypi_command (
@@ -468,7 +468,7 @@ def test_verify_pypi_invalid_url(
468468    assert  "Unsupported/invalid URL"  in  caplog .text 
469469
470470
471- def  test_verify_pypi_invalid_file_name (
471+ def  test_verify_pypi_invalid_file_name_url (
472472    caplog : pytest .LogCaptureFixture , monkeypatch : pytest .MonkeyPatch 
473473) ->  None :
474474    # Failure because file is neither a wheer nor a sdist 
@@ -503,6 +503,41 @@ def test_verify_pypi_invalid_file_name(
503503    assert  "Invalid wheel filename"  in  caplog .text 
504504
505505
506+ def  test_verify_pypi_invalid_sdist_filename_pypi (
507+     caplog : pytest .LogCaptureFixture , monkeypatch : pytest .MonkeyPatch 
508+ ) ->  None :
509+     # Failure because file is neither a wheer nor a sdist 
510+     monkeypatch .setattr (pypi_attestations ._cli , "_download_file" , lambda  url , dest : None )
511+     with  pytest .raises (SystemExit ):
512+         run_main_with_command (
513+             [
514+                 "verify" ,
515+                 "pypi" ,
516+                 "--repository" ,
517+                 "https://github.com/sigstore/sigstore-python" ,
518+                 f"pypi:{ pypi_wheel_filename }  ,
519+             ]
520+         )
521+     assert  (
522+         "File should be a wheel (*.whl) or a source distribution (*.zip or *.tar.gz)"  in  caplog .text 
523+     )
524+ 
525+     caplog .clear ()
526+ 
527+     """Test that invalid sdist filenames are properly handled.""" 
528+     with  pytest .raises (SystemExit ):
529+         run_main_with_command (
530+             [
531+                 "verify" ,
532+                 "pypi" ,
533+                 "--repository" ,
534+                 "https://github.com/sigstore/sigstore-python" ,
535+                 "pypi:invalid-sdist-name.tar.gz" ,  # Invalid sdist filename format 
536+             ]
537+         )
538+     assert  "Invalid distribution filename:"  in  caplog .text 
539+ 
540+ 
506541@online  
507542def  test_verify_pypi_validation_fails (
508543    caplog : pytest .LogCaptureFixture , monkeypatch : pytest .MonkeyPatch 
@@ -575,10 +610,10 @@ def test_verify_pypi_error_finding_package_info(
575610                "pypi" ,
576611                "--repository" ,
577612                "https://github.com/sigstore/sigstore-python" ,
578-                 "somepkg/ somefile" ,
613+                 "pypi: somefile-1.0.0.tar.gz " ,
579614            ]
580615        )
581-     assert  "Error trying to get information for 'somepkg ' from PyPI: myerror"  in  caplog .text 
616+     assert  "Error trying to get information for 'somefile ' from PyPI: myerror"  in  caplog .text 
582617
583618
584619def  test_verify_pypi_error_finding_artifact_url (
@@ -594,10 +629,10 @@ def test_verify_pypi_error_finding_artifact_url(
594629                "pypi" ,
595630                "--repository" ,
596631                "https://github.com/sigstore/sigstore-python" ,
597-                 "somepkg/ somefile" ,
632+                 "pypi: somefile-1.0.0.tar.gz " ,
598633            ]
599634        )
600-     assert  "Could not find the artifact 'somefile' for 'somepkg' "  in  caplog .text 
635+     assert  "Could not find the artifact 'somefile-1.0.0.tar.gz' on PyPI "  in  caplog .text 
601636
602637
603638def  test_verify_pypi_error_validating_provenance (
0 commit comments