@@ -292,6 +292,12 @@ func TestParseRequirementsTxt_FileFormatExample(t *testing.T) {
292292 Ecosystem : lockfile .PipEcosystem ,
293293 CompareAs : lockfile .PipEcosystem ,
294294 },
295+ {
296+ Name : "django" ,
297+ Version : "2.2.24" ,
298+ Ecosystem : lockfile .PipEcosystem ,
299+ CompareAs : lockfile .PipEcosystem ,
300+ },
295301 })
296302}
297303
@@ -344,3 +350,85 @@ func TestParseRequirementsTxt_NonNormalizedNames(t *testing.T) {
344350 },
345351 })
346352}
353+
354+ func TestParseRequirementsTxt_WithMultipleROptions (t * testing.T ) {
355+ t .Parallel ()
356+
357+ packages , err := lockfile .ParseRequirementsTxt ("fixtures/pip/with-multiple-r-options.txt" )
358+
359+ if err != nil {
360+ t .Errorf ("Got unexpected error: %v" , err )
361+ }
362+
363+ expectPackages (t , packages , []lockfile.PackageDetails {
364+ {
365+ Name : "flask" ,
366+ Version : "0.0.0" ,
367+ Ecosystem : lockfile .PipEcosystem ,
368+ CompareAs : lockfile .PipEcosystem ,
369+ },
370+ {
371+ Name : "flask-cors" ,
372+ Version : "0.0.0" ,
373+ Ecosystem : lockfile .PipEcosystem ,
374+ CompareAs : lockfile .PipEcosystem ,
375+ },
376+ {
377+ Name : "pandas" ,
378+ Version : "0.23.4" ,
379+ Ecosystem : lockfile .PipEcosystem ,
380+ CompareAs : lockfile .PipEcosystem ,
381+ },
382+ {
383+ Name : "numpy" ,
384+ Version : "1.16.0" ,
385+ Ecosystem : lockfile .PipEcosystem ,
386+ CompareAs : lockfile .PipEcosystem ,
387+ },
388+ {
389+ Name : "scikit-learn" ,
390+ Version : "0.20.1" ,
391+ Ecosystem : lockfile .PipEcosystem ,
392+ CompareAs : lockfile .PipEcosystem ,
393+ },
394+ {
395+ Name : "sklearn" ,
396+ Version : "0.0.0" ,
397+ Ecosystem : lockfile .PipEcosystem ,
398+ CompareAs : lockfile .PipEcosystem ,
399+ },
400+ {
401+ Name : "requests" ,
402+ Version : "0.0.0" ,
403+ Ecosystem : lockfile .PipEcosystem ,
404+ CompareAs : lockfile .PipEcosystem ,
405+ },
406+ {
407+ Name : "gevent" ,
408+ Version : "0.0.0" ,
409+ Ecosystem : lockfile .PipEcosystem ,
410+ CompareAs : lockfile .PipEcosystem ,
411+ },
412+ {
413+ Name : "requests" ,
414+ Version : "1.2.3" ,
415+ Ecosystem : lockfile .PipEcosystem ,
416+ CompareAs : lockfile .PipEcosystem ,
417+ },
418+ {
419+ Name : "django" ,
420+ Version : "2.2.24" ,
421+ Ecosystem : lockfile .PipEcosystem ,
422+ CompareAs : lockfile .PipEcosystem ,
423+ },
424+ })
425+ }
426+
427+ func TestParseRequirementsTxt_WithBadROption (t * testing.T ) {
428+ t .Parallel ()
429+
430+ packages , err := lockfile .ParseRequirementsTxt ("fixtures/pip/with-bad-r-option.txt" )
431+
432+ expectErrContaining (t , err , "could not open" )
433+ expectPackages (t , packages , []lockfile.PackageDetails {})
434+ }
0 commit comments