@@ -60,6 +60,39 @@ def test_version_cloud_server_type():
60
60
)
61
61
62
62
63
+ @pytest .mark .usefixtures ("disable_hosted_api_server" )
64
+ def test_version_handles_none_metadata_names (monkeypatch : pytest .MonkeyPatch ):
65
+ """Test that version command handles packages with None metadata names gracefully."""
66
+
67
+ class MockDistribution :
68
+ def __init__ (self , metadata : dict [str , str | None ], version : str = "1.0.0" ):
69
+ self .metadata = metadata
70
+ self .version = version
71
+
72
+ mock_distributions = [
73
+ MockDistribution (
74
+ {"Name" : "prefect-aws" , "Author-email" : "help@prefect.io>" }, "2.0.0"
75
+ ),
76
+ MockDistribution ({"Name" : None , "Author-email" : "help@prefect.io>" }),
77
+ MockDistribution ({"Author-email" : "help@prefect.io>" }),
78
+ MockDistribution (
79
+ {"Name" : "some-other-package" , "Author-email" : "other@example.com" }
80
+ ),
81
+ ]
82
+
83
+ def mock_distributions_func ():
84
+ return mock_distributions
85
+
86
+ monkeypatch .setattr ("importlib.metadata.distributions" , mock_distributions_func )
87
+
88
+ result = invoke_and_assert (
89
+ ["version" ],
90
+ expected_code = 0 ,
91
+ )
92
+ assert "prefect-aws" in result .output
93
+ assert "2.0.0" in result .output
94
+
95
+
63
96
@pytest .mark .usefixtures ("disable_hosted_api_server" )
64
97
def test_correct_output_ephemeral_sqlite (monkeypatch : pytest .MonkeyPatch ):
65
98
version_info = prefect .__version_info__
0 commit comments