File tree Expand file tree Collapse file tree
StabilityMatrix.Core/Python
StabilityMatrix.Tests/Core Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -64,10 +64,20 @@ public static PipShowResult Parse(string output)
6464 linesDict . TryAdd ( key , value ) ;
6565 }
6666
67+ if ( ! linesDict . TryGetValue ( "Name" , out var name ) )
68+ {
69+ throw new FormatException ( "The 'Name' key was not found in the pip show output." ) ;
70+ }
71+
72+ if ( ! linesDict . TryGetValue ( "Version" , out var version ) )
73+ {
74+ throw new FormatException ( "The 'Version' key was not found in the pip show output." ) ;
75+ }
76+
6777 return new PipShowResult
6878 {
69- Name = linesDict [ "Name" ] ,
70- Version = linesDict [ "Version" ] ,
79+ Name = name ,
80+ Version = version ,
7181 Summary = linesDict . GetValueOrDefault ( "Summary" ) ,
7282 HomePage = linesDict . GetValueOrDefault ( "Home-page" ) ,
7383 Author = linesDict . GetValueOrDefault ( "Author" ) ,
Original file line number Diff line number Diff line change @@ -174,4 +174,11 @@ public void TestDuplicatePackageNameInOutput()
174174 Assert . AreEqual ( "package-a" , result . Name ) ;
175175 Assert . AreEqual ( "1.0.0" , result . Version ) ;
176176 }
177+
178+ [ TestMethod ]
179+ public void TestEmptyInputThrowsFormatException ( )
180+ {
181+ var input = "" ;
182+ Assert . ThrowsException < FormatException > ( ( ) => PipShowResult . Parse ( input ) ) ;
183+ }
177184}
You can’t perform that action at this time.
0 commit comments