@@ -20,34 +20,62 @@ load("//python/private/pypi:index_sources.bzl", "index_sources")  # buildifier:
2020_tests  =  []
2121
2222def  _test_no_simple_api_sources (env ):
23-     inputs  =  [
24-         "foo==0.0.1" ,
25-         "foo==0.0.1 @ https://someurl.org" ,
26-         "foo==0.0.1 @ https://someurl.org --hash=sha256:deadbeef" ,
27-         "foo==0.0.1 @ https://someurl.org; python_version < 2.7 --hash=sha256:deadbeef" ,
28-     ]
29-     for  input  in  inputs :
23+     inputs  =  {
24+         "foo==0.0.1" : struct (
25+             requirement  =  "foo==0.0.1" ,
26+             marker  =  "" ,
27+         ),
28+         "foo==0.0.1 @ https://someurl.org" : struct (
29+             requirement  =  "foo==0.0.1 @ https://someurl.org" ,
30+             marker  =  "" ,
31+         ),
32+         "foo==0.0.1 @ https://someurl.org --hash=sha256:deadbeef" : struct (
33+             requirement  =  "foo==0.0.1 @ https://someurl.org --hash=sha256:deadbeef" ,
34+             marker  =  "" ,
35+         ),
36+         "foo==0.0.1 @ https://someurl.org; python_version < \" 2.7\" \\     --hash=sha256:deadbeef" : struct (
37+             requirement  =  "foo==0.0.1 @ https://someurl.org --hash=sha256:deadbeef" ,
38+             marker  =  "python_version < \" 2.7\" " ,
39+         ),
40+     }
41+     for  input , want  in  inputs .items ():
3042        got  =  index_sources (input )
3143        env .expect .that_collection (got .shas ).contains_exactly ([])
3244        env .expect .that_str (got .version ).equals ("0.0.1" )
45+         env .expect .that_str (got .requirement ).equals (want .requirement )
46+         env .expect .that_str (got .requirement_line ).equals (got .requirement )
47+         env .expect .that_str (got .marker ).equals (want .marker )
3348
3449_tests .append (_test_no_simple_api_sources )
3550
3651def  _test_simple_api_sources (env ):
3752    tests  =  {
38-         "foo==0.0.2 --hash=sha256:deafbeef    --hash=sha256:deadbeef" : [
39-             "deadbeef" ,
40-             "deafbeef" ,
41-         ],
42-         "foo[extra]==0.0.2; (python_version < 2.7 or something_else == \" @\" ) --hash=sha256:deafbeef    --hash=sha256:deadbeef" : [
43-             "deadbeef" ,
44-             "deafbeef" ,
45-         ],
53+         "foo==0.0.2 --hash=sha256:deafbeef    --hash=sha256:deadbeef" : struct (
54+             shas  =  [
55+                 "deadbeef" ,
56+                 "deafbeef" ,
57+             ],
58+             marker  =  "" ,
59+             requirement  =  "foo==0.0.2" ,
60+             requirement_line  =  "foo==0.0.2 --hash=sha256:deafbeef --hash=sha256:deadbeef" ,
61+         ),
62+         "foo[extra]==0.0.2; (python_version < 2.7 or extra == \" @\" ) --hash=sha256:deafbeef    --hash=sha256:deadbeef" : struct (
63+             shas  =  [
64+                 "deadbeef" ,
65+                 "deafbeef" ,
66+             ],
67+             marker  =  "(python_version < 2.7 or extra == \" @\" )" ,
68+             requirement  =  "foo[extra]==0.0.2" ,
69+             requirement_line  =  "foo[extra]==0.0.2 --hash=sha256:deafbeef --hash=sha256:deadbeef" ,
70+         ),
4671    }
47-     for  input , want_shas  in  tests .items ():
72+     for  input , want  in  tests .items ():
4873        got  =  index_sources (input )
49-         env .expect .that_collection (got .shas ).contains_exactly (want_shas )
74+         env .expect .that_collection (got .shas ).contains_exactly (want . shas )
5075        env .expect .that_str (got .version ).equals ("0.0.2" )
76+         env .expect .that_str (got .requirement ).equals (want .requirement )
77+         env .expect .that_str (got .requirement_line ).equals (want .requirement_line )
78+         env .expect .that_str (got .marker ).equals (want .marker )
5179
5280_tests .append (_test_simple_api_sources )
5381
0 commit comments